Skip to content

Commit f9eb812

Browse files
committed
chore: Ensure to install nested packages with install command
1 parent bd67950 commit f9eb812

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"license": "Apache",
66
"scripts": {
77
"lint": "eslint --ignore-path .gitignore .",
8+
"postinstall": "./scripts/install-nested-packages.js",
89
"test": "jest --bail 1 --testEnvironment node ./tests/integration.test.js"
910
},
1011
"devDependencies": {

scripts/install-nested-packages.js

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env node
2+
3+
'use strict';
4+
5+
process.on('unhandledRejection', (reason) => {
6+
throw reason;
7+
});
8+
9+
const path = require('path');
10+
const childProcess = require('child_process');
11+
12+
const platformRoot = path.resolve(__dirname, '..');
13+
14+
const npmInstall = (packagePath) =>
15+
new Promise((resolve, reject) => {
16+
console.log('---------------------------------------');
17+
console.log(`Install \x1b[33m${packagePath}\x1b[39m ...\n`);
18+
const child = childProcess.spawn('npm', ['install'], {
19+
cwd: path.resolve(platformRoot, packagePath),
20+
stdio: 'inherit',
21+
});
22+
child.on('error', reject);
23+
child.on('close', (code) => {
24+
if (code) {
25+
reject(new Error(`npm install failed at ${packagePath}`));
26+
} else {
27+
resolve();
28+
}
29+
});
30+
});
31+
32+
const packagesPaths = ['src'];
33+
34+
(async () => {
35+
// Running multiple "npm install" prcesses in parallel is not confirmed to be safe.
36+
for (const packagePath of packagesPaths) {
37+
await npmInstall(packagePath);
38+
}
39+
})();

0 commit comments

Comments
 (0)