From 46eaae95974b8ea0ff8a2c4c12a2a3f93d78b3b3 Mon Sep 17 00:00:00 2001 From: sebastien Date: Fri, 28 Feb 2025 11:45:05 +0100 Subject: [PATCH] simplify getFileCommitDate --- packages/docusaurus-utils/src/gitUtils.ts | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/packages/docusaurus-utils/src/gitUtils.ts b/packages/docusaurus-utils/src/gitUtils.ts index 83f3760aff..104bf73634 100644 --- a/packages/docusaurus-utils/src/gitUtils.ts +++ b/packages/docusaurus-utils/src/gitUtils.ts @@ -129,22 +129,16 @@ export async function getFileCommitDate( file, )}"`; - async function executeCommand(cmd: string, filepath: string) { - const {exitCode, stdout, stderr} = await execa(cmd, { - cwd: path.dirname(filepath), - shell: true, - }); - if (exitCode !== 0) { - throw new Error( - `Failed to retrieve the git history for file "${file}" with exit code ${exitCode}: ${stderr}`, - ); - } - return {code: exitCode, stdout, stderr}; + const result = await execa(command, { + cwd: path.dirname(file), + shell: true, + }); + if (result.exitCode !== 0) { + throw new Error( + `Failed to retrieve the git history for file "${file}" with exit code ${result.exitCode}: ${result.stderr}`, + ); } - // Usage - const result = await executeCommand(command, file); - // We only parse the output line starting with our "RESULT:" prefix // See why https://github.com/facebook/docusaurus/pull/10022 const regex = includeAuthor