Skip to content

Commit f964391

Browse files
DvdGiessenkefranabg
authored andcommitted
fix($last-updated): use file author time instead of submodule commit time (#1640)
1 parent 74017c5 commit f964391

File tree

1 file changed

+6
-1
lines changed
  • packages/@vuepress/plugin-last-updated

1 file changed

+6
-1
lines changed

packages/@vuepress/plugin-last-updated/index.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const path = require('path')
12
const spawn = require('cross-spawn')
23

34
module.exports = (options = {}, context) => ({
@@ -21,7 +22,11 @@ function defaultTransformer (timestamp, lang) {
2122
function getGitLastUpdatedTimeStamp (filePath) {
2223
let lastUpdated
2324
try {
24-
lastUpdated = parseInt(spawn.sync('git', ['log', '-1', '--format=%ct', filePath]).stdout.toString('utf-8')) * 1000
25+
lastUpdated = parseInt(spawn.sync(
26+
'git',
27+
['log', '-1', '--format=%at', path.basename(filePath)],
28+
{ cwd: path.dirname(filePath) }
29+
).stdout.toString('utf-8')) * 1000
2530
} catch (e) { /* do not handle for now */ }
2631
return lastUpdated
2732
}

0 commit comments

Comments
 (0)