Skip to content

Commit

Permalink
Fix again
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Cena committed Nov 8, 2021
1 parent 1015bac commit 593c16e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('lastUpdate', () => {
expect(await getFileLastUpdate(nonExistingFilePath)).toBeNull();
expect(consoleMock).toHaveBeenCalledTimes(1);
expect(consoleMock.mock.calls[0][0].message).toContain(
'unknown revision or path not in the working tree.',
' with exit code 128',
);
expect(await getFileLastUpdate(null)).toBeNull();
expect(await getFileLastUpdate(undefined)).toBeNull();
Expand Down
6 changes: 4 additions & 2 deletions packages/docusaurus-plugin-content-docs/src/lastUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ export async function getFileLastUpdate(
}

const result = shell.exec(`git log -1 --format=%ct,%an ${filePath}`);
if (result.stderr) {
throw new Error(result.stderr);
if (result.code !== 0) {
throw new Error(
`Retrieval of git history failed at ${filePath} with exit code ${result.code}: ${result.stderr}`,
);
}
return getTimestampAndAuthor(result.stdout.trim());
} catch (error) {
Expand Down

0 comments on commit 593c16e

Please sign in to comment.