@@ -4,79 +4,78 @@ var shell = require('shelljs'),
4
4
fs = require ( 'fs' ) ,
5
5
exists ,
6
6
codegen ,
7
+ codegens ,
7
8
codegen_path ,
8
9
getSubfolders ,
9
10
individual_test ,
10
- commandOut ,
11
- pwd = shell . pwd ( ) ;
11
+ commandOut ;
12
12
13
- const args = process . argv [ 2 ] ,
13
+ const args = process . argv [ 2 ] ,
14
14
PATH_TO_CODEGENS_FOLDER = path . resolve ( __dirname , '../codegens' ) ;
15
15
16
16
// throw JS error when any shell.js command encounters an error
17
- shell . config . fatal = true ;
17
+ shell . config . fatal = true ;
18
18
19
19
// ensure that the working tree is clean before packaging
20
20
commandOut = shell . exec ( 'source ./npm/package/require_clean_work_tree.sh' ) ;
21
21
if ( commandOut . code !== 0 ) {
22
- shell . exit ( 1 ) ;
22
+ shell . exit ( 1 ) ;
23
23
}
24
24
25
25
getSubfolders = ( folder ) => {
26
- return fs . readdirSync ( folder )
27
- . map ( ( subfolder ) => { return { path : path . join ( folder , subfolder ) , name : subfolder } ; } )
28
- . filter ( ( obj ) => { return fs . statSync ( obj . path ) . isDirectory ( ) ; } ) ;
26
+ return fs . readdirSync ( folder )
27
+ . map ( ( subfolder ) => { return { path : path . join ( folder , subfolder ) , name : subfolder } ; } )
28
+ . filter ( ( obj ) => { return fs . statSync ( obj . path ) . isDirectory ( ) ; } ) ;
29
29
} ;
30
30
31
31
individual_test = ( codegen ) => {
32
32
33
- console . log ( `Creating package for ${ codegen } ` ) ;
34
- async . series ( [
35
- function ( next ) {
36
- console . log ( `Running codegen test for codegen ${ codegen } ` ) ;
37
- commandOut = shell . exec ( `npm run test ${ codegen } --color always` , { silent : true } ) ;
38
- if ( commandOut . code !== 0 ) {
39
- console . error ( `Failed to run codegen test on codegen ${ codegen } , here\ 's the error:` ) ;
40
- return next ( commandOut . stderr ) ;
41
- }
42
- console . log ( commandOut . stdout ) ;
43
- return next ( ) ;
44
- } ,
45
- function ( next ) {
46
- console . log ( `Generating zip for codegen ${ codegen } ` ) ;
47
- commandOut = shell . exec ( `npm run zip ${ codegen } --color always` , { silent : true } ) ;
48
- if ( commandOut . code !== 0 ) {
49
- console . error ( `Failed to zip codegen ${ codegen } , here\ 's the error:` ) ;
50
- return next ( commandOut . stderr ) ;
51
- }
52
- console . log ( commandOut . stdout ) ;
53
- }
54
- ] , ( err ) => {
55
- console . error ( err ) ;
56
- shell . exit ( 1 ) ;
57
- } ) ;
58
- }
33
+ console . log ( `Creating package for ${ codegen } ` ) ;
34
+ async . series ( [
35
+ function ( next ) {
36
+ console . log ( `Running codegen test for codegen ${ codegen } ` ) ;
37
+ commandOut = shell . exec ( `npm run test ${ codegen } --color always` ) ;
38
+ if ( commandOut . code !== 0 ) {
39
+ console . error ( `Failed to run codegen test on codegen ${ codegen } , here's the error:` ) ;
40
+ return next ( commandOut . stderr ) ;
41
+ }
42
+ console . log ( commandOut . stdout ) ;
43
+ return next ( ) ;
44
+ } ,
45
+ function ( next ) {
46
+ console . log ( `Generating zip for codegen ${ codegen } ` ) ;
47
+ commandOut = shell . exec ( `npm run zip ${ codegen } --color always` ) ;
48
+ if ( commandOut . code !== 0 ) {
49
+ console . error ( `Failed to zip codegen ${ codegen } , here's the error:` ) ;
50
+ return next ( commandOut . stderr ) ;
51
+ }
52
+ console . log ( commandOut . stdout ) ;
53
+ }
54
+ ] , ( err ) => {
55
+ console . error ( err ) ;
56
+ shell . exit ( 1 ) ;
57
+ } ) ;
58
+ } ;
59
59
60
60
if ( args ) {
61
- codegen = args ;
62
- codegen_path = path . join ( PATH_TO_CODEGENS_FOLDER , codegen ) ;
63
- try {
64
- exists = fs . statSync ( codegen_path ) . isDirectory ( ) ;
65
- } catch ( err ) {
66
- console . log ( `Codegen ${ codegen } doesn't exist, please enter a valid name` ) ;
67
- console . log ( err ) ;
68
- shell . exit ( 1 ) ;
69
- }
70
- if ( exists ) {
71
- individual_test ( codegen ) ;
72
- }
61
+ codegen = args ;
62
+ codegen_path = path . join ( PATH_TO_CODEGENS_FOLDER , codegen ) ;
63
+ try {
64
+ exists = fs . statSync ( codegen_path ) . isDirectory ( ) ;
65
+ }
66
+ catch ( err ) {
67
+ console . log ( `Codegen ${ codegen } doesn't exist, please enter a valid name` ) ;
68
+ console . log ( err ) ;
69
+ shell . exit ( 1 ) ;
70
+ }
71
+ if ( exists ) {
72
+ individual_test ( codegen ) ;
73
+ }
73
74
}
74
75
else {
75
- console . log ( 'Packaging all the codegens' ) ;
76
- var codegens = getSubfolders ( PATH_TO_CODEGENS_FOLDER ) ;
77
- codegens . forEach ( ( codegen ) => {
78
- individual_test ( codegen . name ) ;
79
- } ) ;
76
+ console . log ( 'Packaging all the codegens' ) ;
77
+ codegens = getSubfolders ( PATH_TO_CODEGENS_FOLDER ) ;
78
+ codegens . forEach ( ( codegen ) => {
79
+ individual_test ( codegen . name ) ;
80
+ } ) ;
80
81
}
81
-
82
-
0 commit comments