File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 55 "license" : " Apache" ,
66 "scripts" : {
77 "lint" : " eslint --ignore-path .gitignore ." ,
8+ "postinstall" : " ./scripts/install-nested-packages.js" ,
89 "test" : " jest ./tests/integration.test.js --testEnvironment node"
910 },
1011 "devDependencies" : {
Original file line number Diff line number Diff line change 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+ } ) ( ) ;
You can’t perform that action at this time.
0 commit comments