@@ -28,10 +28,10 @@ var isBuilding = false;
2828var ninjaFile = require ( "./ninja.js" ) ;
2929var jscompDir = path . join ( ".." , "jscomp" ) ;
3030function rebuild ( ) {
31- console . log ( ">>>> Start compiling" ) ;
3231 if ( isBuilding ) {
3332 buildAppending = true ;
3433 } else {
34+ console . log ( ">>>> Start compiling" ) ;
3535 isBuilding = true ;
3636 var p = cp . spawn ( ninjaFile . vendorNinjaPath , [ ] , {
3737 stdio : [ "inherit" , "inherit" , "pipe" ]
@@ -54,7 +54,7 @@ function buildFinished(code, signal) {
5454 console . log ( `File "BUILD", line 1, characters 1-1:` ) ;
5555 console . log ( `Error: Failed to build` ) ;
5656 }
57- console . log ( ">>>> Finish compiling" ) ;
57+ console . log ( ">>>> Finish compiling (options: R|clean|config) " ) ;
5858 // TODO: check ninja exit error code
5959 if ( code === 0 ) {
6060 // This is not always correct
@@ -78,3 +78,45 @@ sourceDirs.forEach(x => {
7878 fs . watch ( path . join ( jscompDir , x ) , "utf8" , onSourceChange ) ;
7979} ) ;
8080rebuild ( ) ;
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