fix(build): remove dependency on *nix chown

This commit is contained in:
Waldemar Reusch
2023-01-12 22:27:22 +01:00
parent 016b15b437
commit b5484740b7

View File

@ -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<string>(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<string>(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);
});
});