@@ -28,10 +28,10 @@ var isBuilding = false;
28
28
var ninjaFile = require ( "./ninja.js" ) ;
29
29
var jscompDir = path . join ( ".." , "jscomp" ) ;
30
30
function rebuild ( ) {
31
- console . log ( ">>>> Start compiling" ) ;
32
31
if ( isBuilding ) {
33
32
buildAppending = true ;
34
33
} else {
34
+ console . log ( ">>>> Start compiling" ) ;
35
35
isBuilding = true ;
36
36
var p = cp . spawn ( ninjaFile . vendorNinjaPath , [ ] , {
37
37
stdio : [ "inherit" , "inherit" , "pipe" ]
@@ -54,7 +54,7 @@ function buildFinished(code, signal) {
54
54
console . log ( `File "BUILD", line 1, characters 1-1:` ) ;
55
55
console . log ( `Error: Failed to build` ) ;
56
56
}
57
- console . log ( ">>>> Finish compiling" ) ;
57
+ console . log ( ">>>> Finish compiling (options: R|clean|config) " ) ;
58
58
// TODO: check ninja exit error code
59
59
if ( code === 0 ) {
60
60
// This is not always correct
@@ -78,3 +78,45 @@ sourceDirs.forEach(x => {
78
78
fs . watch ( path . join ( jscompDir , x ) , "utf8" , onSourceChange ) ;
79
79
} ) ;
80
80
rebuild ( ) ;
81
+
82
+ const readline = require ( "readline" ) ;
83
+
84
+ const rl = readline . createInterface ( {
85
+ input : process . stdin ,
86
+ output : process . stdout
87
+ } ) ;
88
+
89
+ var child_process = require ( "child_process" ) ;
90
+ rl . on ( "line" , input => {
91
+ switch ( input . toLowerCase ( ) ) {
92
+ case "r" :
93
+ rebuild ( ) ;
94
+ break ;
95
+ case "config" :
96
+ if ( isBuilding ) {
97
+ console . log ( `it's building` ) ;
98
+ } else {
99
+ isBuilding = true ;
100
+ child_process
101
+ . fork ( path . join ( __dirname , "ninja.js" ) , [ "config" ] )
102
+ . on ( "close" , ( ) => {
103
+ isBuilding = false ;
104
+ rebuild ( ) ;
105
+ } ) ;
106
+ }
107
+ break ;
108
+ case "clean" :
109
+ if ( isBuilding ) {
110
+ console . log ( `it's building` ) ;
111
+ } else {
112
+ isBuilding = true ;
113
+ child_process
114
+ . fork ( path . join ( __dirname , "ninja.js" ) , [ "cleanbuild" ] )
115
+ . on ( "close" , ( ) => {
116
+ isBuilding = false ;
117
+ } ) ;
118
+ }
119
+
120
+ break ;
121
+ }
122
+ } ) ;
0 commit comments