Skip to content
This repository has been archived by the owner on Aug 18, 2024. It is now read-only.

Commit

Permalink
fix: wait for scripts to finish before running the next one
Browse files Browse the repository at this point in the history
  • Loading branch information
dominykas committed Jan 29, 2019
1 parent 04dd93c commit 77c8c4c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
6 changes: 5 additions & 1 deletion bin/allow-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@

const Allow = require('..');

Allow.run();
Allow.run().catch((err) => {

console.error(err);
process.exit(1);
});
18 changes: 13 additions & 5 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ internals.runScript = (stage, { childPkg, path, cwd }) => {
console.log();
console.log(`==========> ${stage} ${path}...`);

Npm.runScript(childPkg, stage, Path.join(cwd, path), {
return Npm.runScript(childPkg, stage, Path.join(cwd, path), {
dir: cwd,
log: Object.assign({
pause: () => {},
Expand All @@ -66,7 +66,7 @@ internals.runScript = (stage, { childPkg, path, cwd }) => {
});
};

exports.run = (cmd = 'install') => {
exports.run = async (cmd = 'install') => {

const cwd = process.cwd();
const pkg = require(Path.join(cwd, 'package.json'));
Expand Down Expand Up @@ -103,7 +103,15 @@ exports.run = (cmd = 'install') => {
return allowScripts[name];
});

allowedScripts.forEach(([path, childPkg]) => internals.runScript('preinstall', { childPkg, path, cwd }));
allowedScripts.forEach(([path, childPkg]) => internals.runScript('install', { childPkg, path, cwd }));
allowedScripts.forEach(([path, childPkg]) => internals.runScript('postinstall', { childPkg, path, cwd }));
for (const [path, childPkg] of allowedScripts) {
await internals.runScript('preinstall', { childPkg, path, cwd });
}

for (const [path, childPkg] of allowedScripts) {
await internals.runScript('install', { childPkg, path, cwd });
}

for (const [path, childPkg] of allowedScripts) {
await internals.runScript('postinstall', { childPkg, path, cwd });
}
};

0 comments on commit 77c8c4c

Please sign in to comment.