File tree Expand file tree Collapse file tree 3 files changed +30
-1
lines changed Expand file tree Collapse file tree 3 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 1+ # In the script, we use syntax that this version of ESLint can't parse
2+ postinstall.js
Original file line number Diff line number Diff line change 2626 "test:runner" : " mocha tests/testrunner-tests.js" ,
2727 "test" : " npm-run-all test:*" ,
2828 "release" : " release-it" ,
29- "postinstall" : " npm run build "
29+ "postinstall" : " node postinstall.js "
3030 },
3131 "repository" : {
3232 "type" : " git" ,
Original file line number Diff line number Diff line change 1+ // The script is compatible with Node.js 10+
2+
3+ const { execSync } = require ( 'child_process' ) ;
4+ const { resolve } = require ( 'path' ) ;
5+
6+ function gulpInstalled ( ) {
7+ try {
8+ require . resolve ( 'gulp' ) ;
9+ return true ;
10+ }
11+ catch {
12+ return false ;
13+ }
14+ }
15+
16+ const root = resolve ( __dirname , '.' ) ;
17+
18+ if ( ! gulpInstalled ( ) ) {
19+ console . log ( '[postinstall] Dependencies missing — installing...' ) ;
20+ execSync ( 'npm install' , { cwd : root , stdio : 'inherit' } ) ;
21+ }
22+ else {
23+ console . log ( '[postinstall] Dependencies already installed.' ) ;
24+ }
25+
26+ console . log ( '[postinstall] Running build...' ) ;
27+ execSync ( 'npm run build' , { cwd : root , stdio : 'inherit' } ) ;
You can’t perform that action at this time.
0 commit comments