Skip to content

Commit 4c23003

Browse files
authored
fix(build): make lastUpdated work with git submodules (#2149)
1 parent 51ecd58 commit 4c23003

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/node/markdownToVue.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export async function createMarkdownToVueRenderFn(
187187
}
188188

189189
if (includeLastUpdatedData) {
190-
pageData.lastUpdated = await getGitTimestamp(file)
190+
pageData.lastUpdated = await getGitTimestamp(fileOrig)
191191
}
192192

193193
if (siteConfig?.transformPageData) {

src/node/utils/getGitTimestamp.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
import { spawn } from 'cross-spawn'
2+
import { basename, dirname } from 'path'
23

34
export function getGitTimestamp(file: string) {
45
return new Promise<number>((resolve, reject) => {
5-
const child = spawn('git', ['log', '-1', '--pretty="%ci"', file])
6+
const cwd = dirname(file)
7+
const fileName = basename(file)
8+
const child = spawn('git', ['log', '-1', '--pretty="%ci"', fileName], {
9+
cwd
10+
})
611
let output = ''
712
child.stdout.on('data', (d) => (output += String(d)))
813
child.on('close', () => {

0 commit comments

Comments
 (0)