Skip to content

Commit

Permalink
fix($last-updated): use file author time instead of submodule commit …
Browse files Browse the repository at this point in the history
…time (#1640)
  • Loading branch information
DvdGiessen authored and kefranabg committed Sep 10, 2019
1 parent 74017c5 commit f964391
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/@vuepress/plugin-last-updated/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const path = require('path')
const spawn = require('cross-spawn')

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

0 comments on commit f964391

Please sign in to comment.