From f9643917a13876d88b461c16da43ff44bf160636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20de=20Giessen?= Date: Tue, 10 Sep 2019 15:49:32 +0200 Subject: [PATCH] fix($last-updated): use file author time instead of submodule commit time (#1640) --- packages/@vuepress/plugin-last-updated/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/@vuepress/plugin-last-updated/index.js b/packages/@vuepress/plugin-last-updated/index.js index cf307083ad..c845e6a047 100644 --- a/packages/@vuepress/plugin-last-updated/index.js +++ b/packages/@vuepress/plugin-last-updated/index.js @@ -1,3 +1,4 @@ +const path = require('path') const spawn = require('cross-spawn') module.exports = (options = {}, context) => ({ @@ -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 }