From ea73b7407b7e2d0e37f47e3089b93ade2e026a30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Theodor=20N=2E=20Eng=C3=B8y?= Date: Sun, 8 Feb 2026 13:19:36 +0100 Subject: [PATCH] scripts: avoid execSync --- cli/scripts/make-executable.js | 7 +++++-- scripts/update-version.js | 8 ++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/cli/scripts/make-executable.js b/cli/scripts/make-executable.js index f3b8c9024..4290defbe 100755 --- a/cli/scripts/make-executable.js +++ b/cli/scripts/make-executable.js @@ -3,7 +3,7 @@ */ import { promises as fs } from "fs"; import { platform } from "os"; -import { execSync } from "child_process"; +import { spawnSync } from "child_process"; import path from "path"; const TARGET_FILE = path.resolve("build/cli.js"); @@ -12,7 +12,10 @@ async function makeExecutable() { try { // On Unix-like systems (Linux, macOS), use chmod if (platform() !== "win32") { - execSync(`chmod +x "${TARGET_FILE}"`); + const r = spawnSync("chmod", ["+x", TARGET_FILE], { stdio: "inherit" }); + if (r.error) throw r.error; + if (r.status !== 0) + throw new Error(`chmod failed with exit code ${r.status}`); console.log("Made file executable with chmod"); } else { // On Windows, no need to make files "executable" in the Unix sense diff --git a/scripts/update-version.js b/scripts/update-version.js index 91b69f3bf..1fd8f294c 100755 --- a/scripts/update-version.js +++ b/scripts/update-version.js @@ -2,7 +2,7 @@ import fs from "fs"; import path from "path"; -import { execSync } from "child_process"; +import { spawnSync } from "child_process"; import { fileURLToPath } from "url"; const __filename = fileURLToPath(import.meta.url); @@ -84,7 +84,11 @@ console.log(`Updated ${updatedFiles.length} files to version ${newVersion}`); // Update package-lock.json console.log("\nšŸ”’ Updating package-lock.json..."); try { - execSync("npm install", { stdio: "inherit" }); + const npmCmd = process.platform === "win32" ? "npm.cmd" : "npm"; + const r = spawnSync(npmCmd, ["install"], { stdio: "inherit" }); + if (r.error) throw r.error; + if (r.status !== 0) + throw new Error(`npm install failed with exit code ${r.status}`); console.log("āœ… package-lock.json updated successfully"); } catch (error) { console.error("āŒ Failed to update package-lock.json:", error.message);