diff --git a/src/bin/tools/grant-exec-perms.ts b/src/bin/tools/grant-exec-perms.ts index cf7ec725..5f3d53c0 100644 --- a/src/bin/tools/grant-exec-perms.ts +++ b/src/bin/tools/grant-exec-perms.ts @@ -1,10 +1,11 @@ import { getProjectRoot } from "./getProjectRoot"; import { join as pathJoin } from "path"; -import * as child_process from "child_process"; -import * as fs from "fs"; +import { chmodSync, statSync, constants } from "fs"; -Object.entries(JSON.parse(fs.readFileSync(pathJoin(getProjectRoot(), "package.json")).toString("utf8"))["bin"]).forEach(([, scriptPath]) => - child_process.execSync(`chmod +x ${scriptPath}`, { - "cwd": getProjectRoot() - }) -); +import(pathJoin(getProjectRoot(), "package.json")).then(({ bin }) => { + Object.entries(bin).forEach(([, scriptPath]) => { + const fullPath = pathJoin(getProjectRoot(), scriptPath); + const newMode = statSync(fullPath).mode | constants.S_IXUSR | constants.S_IXGRP | constants.S_IXOTH; + chmodSync(fullPath, newMode); + }); +});