diff --git a/src/bin/tools/grant-exec-perms.ts b/src/bin/tools/grant-exec-perms.ts index 5f3d53c0..dab91c6b 100644 --- a/src/bin/tools/grant-exec-perms.ts +++ b/src/bin/tools/grant-exec-perms.ts @@ -1,11 +1,17 @@ import { getProjectRoot } from "./getProjectRoot"; import { join as pathJoin } from "path"; -import { chmodSync, statSync, constants } from "fs"; +import { constants } from "fs"; +import { chmod, stat } from "fs/promises"; -import(pathJoin(getProjectRoot(), "package.json")).then(({ bin }) => { - Object.entries(bin).forEach(([, scriptPath]) => { +async () => { + var { bin } = await import(pathJoin(getProjectRoot(), "package.json")); + + var promises = Object.values(bin).map(async scriptPath => { const fullPath = pathJoin(getProjectRoot(), scriptPath); - const newMode = statSync(fullPath).mode | constants.S_IXUSR | constants.S_IXGRP | constants.S_IXOTH; - chmodSync(fullPath, newMode); + const oldMode = (await stat(fullPath)).mode; + const newMode = oldMode | constants.S_IXUSR | constants.S_IXGRP | constants.S_IXOTH; + await chmod(fullPath, newMode); }); -}); + + await Promise.all(promises); +};