Skip to content

Commit

Permalink
fix(build): make lastUpdated work with git submodules (#2149)
Browse files Browse the repository at this point in the history
  • Loading branch information
chgeo authored Mar 29, 2023
1 parent 51ecd58 commit 4c23003
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/node/markdownToVue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export async function createMarkdownToVueRenderFn(
}

if (includeLastUpdatedData) {
pageData.lastUpdated = await getGitTimestamp(file)
pageData.lastUpdated = await getGitTimestamp(fileOrig)
}

if (siteConfig?.transformPageData) {
Expand Down
7 changes: 6 additions & 1 deletion src/node/utils/getGitTimestamp.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { spawn } from 'cross-spawn'
import { basename, dirname } from 'path'

export function getGitTimestamp(file: string) {
return new Promise<number>((resolve, reject) => {
const child = spawn('git', ['log', '-1', '--pretty="%ci"', file])
const cwd = dirname(file)
const fileName = basename(file)
const child = spawn('git', ['log', '-1', '--pretty="%ci"', fileName], {
cwd
})
let output = ''
child.stdout.on('data', (d) => (output += String(d)))
child.on('close', () => {
Expand Down

0 comments on commit 4c23003

Please sign in to comment.