@@ -4,34 +4,39 @@ var fs = require('fs');
4
4
var path = require ( 'path' ) ;
5
5
var yargs = require ( 'yargs' ) ;
6
6
7
- let args = yargs ( process . argv )
8
- . array ( "path" ) . argv ;
7
+ let frameworks = process . argv . length <= 2 ? [ ] : process . argv . slice ( 2 , process . argv . length ) ;
9
8
10
- for ( let framework of args . path ) {
11
- let dir = 'frameworks/' + framework ;
12
- console . log ( "rebuilding " + framework ) ;
13
- if ( ! fs . existsSync ( dir ) ) console . log ( "ERROR: directory " + dir + " not found" ) ;
14
- else {
15
- console . log ( "running rm -rf package-lock.json yarn.lock dist elm-stuff bower_components node_modules" ) ;
16
- try {
17
- exec ( 'rm -rf package-lock.json yarn.lock dist elm-stuff bower_components node_modules' , {
9
+ if ( frameworks . length === 0 ) {
10
+ console . log ( "usage: rebuild.js [directory1, directory2, ...]" ) ;
11
+ } else {
12
+ for ( let framework of frameworks ) {
13
+ let dir = 'frameworks/' + framework ;
14
+ console . log ( "rebuilding " + framework ) ;
15
+ if ( ! fs . existsSync ( dir ) ) console . log ( "ERROR: directory " + dir + " not found" ) ;
16
+ else {
17
+ console . log ( "running rm -rf package-lock.json yarn.lock dist elm-stuff bower_components node_modules" ) ;
18
+ try {
19
+ exec ( 'rm -rf package-lock.json yarn.lock dist elm-stuff bower_components node_modules' , {
20
+ cwd : dir ,
21
+ stdio : 'inherit'
22
+ } ) ;
23
+ } catch { }
24
+ console . log ( "running npm install && npm run build-prod" ) ;
25
+ exec ( 'npm install && npm run build-prod' , {
18
26
cwd : dir ,
19
27
stdio : 'inherit'
20
28
} ) ;
21
- } catch { }
22
- console . log ( "running npm install && npm run build-prod" ) ;
23
- exec ( 'npm install && npm run build-prod' , {
24
- cwd : dir ,
29
+ }
30
+ }
31
+ exec ( 'npm run index' , {
32
+ cwd : 'webdriver-ts' ,
33
+ stdio : 'inherit'
34
+ } ) ;
35
+ let frameworkNames = frameworks . map ( f => f . split ( "/" ) [ 1 ] ) . join ( " " ) ;
36
+ if ( frameworkNames . length > 1 ) {
37
+ exec ( 'npm run isKeyed -- --framework ' + frameworkNames , {
38
+ cwd : 'webdriver-ts' ,
25
39
stdio : 'inherit'
26
40
} ) ;
27
41
}
28
- }
29
- exec ( 'npm run index' , {
30
- cwd : 'webdriver-ts' ,
31
- stdio : 'inherit'
32
- } ) ;
33
- let frameworkNames = args . path . map ( f => f . split ( "/" ) [ 1 ] ) . join ( " " ) ;
34
- exec ( 'npm run isKeyed -- --framework ' + frameworkNames , {
35
- cwd : 'webdriver-ts' ,
36
- stdio : 'inherit'
37
- } ) ;
42
+ }
0 commit comments