From ac8691767c863a6875c1e67ef2768fecb78ceea9 Mon Sep 17 00:00:00 2001 From: Saneef Ansari Date: Fri, 27 Feb 2026 15:17:24 +0530 Subject: [PATCH] fix: replaces spawn with exec to execute git --- src/utils/git.js | 9 ++++++--- src/utils/spawn.js | 28 ---------------------------- 2 files changed, 6 insertions(+), 31 deletions(-) delete mode 100644 src/utils/spawn.js diff --git a/src/utils/git.js b/src/utils/git.js index 0794a46..f18f9dc 100644 --- a/src/utils/git.js +++ b/src/utils/git.js @@ -1,7 +1,9 @@ -import { resolve } from "path"; -import { spawnAsync } from "./spawn.js"; +import { exec as nodeExec } from "node:child_process"; +import { resolve } from "node:path"; +import { promisify } from "node:util"; const cwd = process.cwd(); +const exec = promisify(nodeExec); /** * Converts relative paths (relative to current working directory) to absolute @@ -80,7 +82,8 @@ function parseGitOutput(str, timeStampMarker = "TS:") { export async function getRepoGitCommitDateMap() { let output; try { - output = await spawnAsync("git", ["log", "--format=TS:%at", "--name-only"]); + const { stdout } = await exec("git log --format=TS:%at --name-only"); + output = stdout.toString(); } catch (e) { console.log(e); throw new Error("Failed to run 'git log'"); diff --git a/src/utils/spawn.js b/src/utils/spawn.js deleted file mode 100644 index f4aa6cc..0000000 --- a/src/utils/spawn.js +++ /dev/null @@ -1,28 +0,0 @@ -import { spawn } from "node:child_process"; - -export function spawnAsync(command, args, options) { - return new Promise((resolve, reject) => { - const cmd = spawn(command, args, options); - const res = []; - cmd.stdout.on("data", (data) => { - res.push(data.toString("utf8")); - }); - - const err = []; - cmd.stderr.on("data", (data) => { - err.push(data.toString("utf8")); - }); - - cmd.on("close", (code) => { - if (err.length > 0) { - reject(err.join("\n")); - } else if (code === 1) { - reject( - new Error("Internal error: process closed with error exit code."), - ); - } else { - resolve(res.join("\n")); - } - }); - }); -}