-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Ensure to install all nested packages on npm install
- Loading branch information
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env node | ||
|
||
'use strict'; | ||
|
||
process.on('unhandledRejection', (reason) => { | ||
throw reason; | ||
}); | ||
|
||
const path = require('path'); | ||
const childProcess = require('child_process'); | ||
|
||
const platformRoot = path.resolve(__dirname, '..'); | ||
|
||
const npmInstall = (packagePath) => | ||
new Promise((resolve, reject) => { | ||
console.log('---------------------------------------'); | ||
console.log(`Install \x1b[33m${packagePath}\x1b[39m ...\n`); | ||
const child = childProcess.spawn('npm', ['install'], { | ||
cwd: path.resolve(platformRoot, packagePath), | ||
stdio: 'inherit', | ||
}); | ||
child.on('error', reject); | ||
child.on('close', (code) => { | ||
if (code) { | ||
reject(new Error(`npm install failed at ${packagePath}`)); | ||
} else { | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
|
||
const packagesPaths = ['src', 'src/_express', 'src/_src', 'test/src']; | ||
|
||
(async () => { | ||
// Running multiple "npm install" prcesses in parallel is not confirmed to be safe. | ||
for (const packagePath of packagesPaths) { | ||
await npmInstall(packagePath); | ||
} | ||
})(); |