mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-27 15:07:53 +02:00
simplify getFileCommitDate
This commit is contained in:
parent
bae2262825
commit
46eaae9597
1 changed files with 8 additions and 14 deletions
|
@ -129,21 +129,15 @@ export async function getFileCommitDate(
|
||||||
file,
|
file,
|
||||||
)}"`;
|
)}"`;
|
||||||
|
|
||||||
async function executeCommand(cmd: string, filepath: string) {
|
const result = await execa(command, {
|
||||||
const {exitCode, stdout, stderr} = await execa(cmd, {
|
cwd: path.dirname(file),
|
||||||
cwd: path.dirname(filepath),
|
|
||||||
shell: true,
|
shell: true,
|
||||||
});
|
});
|
||||||
if (exitCode !== 0) {
|
if (result.exitCode !== 0) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Failed to retrieve the git history for file "${file}" with exit code ${exitCode}: ${stderr}`,
|
`Failed to retrieve the git history for file "${file}" with exit code ${result.exitCode}: ${result.stderr}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return {code: exitCode, stdout, stderr};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Usage
|
|
||||||
const result = await executeCommand(command, file);
|
|
||||||
|
|
||||||
// We only parse the output line starting with our "RESULT:" prefix
|
// We only parse the output line starting with our "RESULT:" prefix
|
||||||
// See why https://github.com/facebook/docusaurus/pull/10022
|
// See why https://github.com/facebook/docusaurus/pull/10022
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue