refactor: follow suggesion to make methods read a bit more sync
This commit is contained in:
parent
1a0e05d073
commit
ae3bfb28ed
@ -1,11 +1,17 @@
|
|||||||
import { getProjectRoot } from "./getProjectRoot";
|
import { getProjectRoot } from "./getProjectRoot";
|
||||||
import { join as pathJoin } from "path";
|
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 }) => {
|
async () => {
|
||||||
Object.entries<string>(bin).forEach(([, scriptPath]) => {
|
var { bin } = await import(pathJoin(getProjectRoot(), "package.json"));
|
||||||
|
|
||||||
|
var promises = Object.values<string>(bin).map(async scriptPath => {
|
||||||
const fullPath = pathJoin(getProjectRoot(), scriptPath);
|
const fullPath = pathJoin(getProjectRoot(), scriptPath);
|
||||||
const newMode = statSync(fullPath).mode | constants.S_IXUSR | constants.S_IXGRP | constants.S_IXOTH;
|
const oldMode = (await stat(fullPath)).mode;
|
||||||
chmodSync(fullPath, newMode);
|
const newMode = oldMode | constants.S_IXUSR | constants.S_IXGRP | constants.S_IXOTH;
|
||||||
|
await chmod(fullPath, newMode);
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
await Promise.all(promises);
|
||||||
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user