test/node_modules/@vuepress/plugin-git/lib/node/utils/getCreatedTime.js
2024-08-13 09:27:52 +08:00

19 lines
464 B
JavaScript

import { execa } from 'execa';
/**
* Get unix timestamp in milliseconds of the first commit
*/
export const getCreatedTime = async (filePaths, cwd) => {
const { stdout } = await execa('git', [
'--no-pager',
'log',
'--follow',
'--diff-filter=A',
'--format=%at',
...filePaths,
], {
cwd,
});
return (Math.min(...stdout.split('\n').map((item) => Number.parseInt(item, 10))) *
1000);
};