mirror of https://github.com/vuejs/vitepress
- The main reason behind this change is because previously the FS-based timestamp is inaccurate and will change on every remote deployment in CI environments, resulting in cache invalidation on every build. Using git timestamps makes them stable. - This is now disabled by default for performance reasons, as getting the git timestamp requires spawning a child process and is expensive. To enable it, use the new `lastUpdated: true` config option.pull/540/head
parent
b404c6671d
commit
d32d8d4419
@ -0,0 +1,13 @@
|
||||
import { spawn } from 'cross-spawn'
|
||||
|
||||
export function getGitTimestamp(file: string) {
|
||||
return new Promise<number>((resolve, reject) => {
|
||||
const child = spawn('git', ['log', '-1', '--pretty="%ci"', file])
|
||||
let output = ''
|
||||
child.stdout.on('data', (d) => (output += String(d)))
|
||||
child.on('close', () => {
|
||||
resolve(+new Date(output))
|
||||
})
|
||||
child.on('error', reject)
|
||||
})
|
||||
}
|
Loading…
Reference in new issue