@@ -194,7 +194,7 @@ class Embark {
194194 engine . startService ( "libraryManager" ) ;
195195 engine . startService ( "codeRunner" ) ;
196196 engine . startService ( "web3" ) ;
197- if ( ! options . onlyCompile ) {
197+ if ( ! options . onlyCompile ) {
198198 engine . startService ( "pipeline" ) ;
199199 }
200200 engine . startService ( "deployment" , { onlyCompile : options . onlyCompile } ) ;
@@ -208,24 +208,30 @@ class Embark {
208208 } ) ;
209209 } ,
210210 function waitForWriteFinish ( callback ) {
211+ if ( options . onlyCompile ) {
212+ engine . logger . info ( "Finished compiling" . underline ) ;
213+ return callback ( null , true ) ;
214+ }
211215 engine . logger . info ( "Finished deploying" . underline ) ;
212- // Necessary log for simple projects. This event is trigger to soon because there is no file
213- // Also, not exiting straight after the deploy leaves time for async afterDeploys to finish
214- if ( options . onlyCompile ) {
216+ if ( ! engine . config . assetFiles || ! Object . keys ( engine . config . assetFiles ) . length ) {
215217 return callback ( ) ;
216218 }
217- engine . logger . info ( "If you have no files to build, you can exit now with CTRL+C" ) ;
218- engine . events . on ( 'outputDone' , callback ) ;
219+ engine . events . on ( 'outputDone' , ( err ) => {
220+ engine . logger . info ( __ ( "finished building" ) . underline ) ;
221+ callback ( err , true ) ;
222+ } ) ;
219223 }
220- ] , function ( err , _result ) {
224+ ] , function ( err , canExit ) {
221225 if ( err ) {
222226 engine . logger . error ( err . message ) ;
223227 engine . logger . debug ( err . stack ) ;
224- } else {
225- engine . logger . info ( __ ( "finished building" ) . underline ) ;
226228 }
227- // needed due to child processes
228- process . exit ( ) ;
229+
230+ if ( canExit || ! engine . config . contractsConfig . afterDeploy || ! engine . config . contractsConfig . afterDeploy . length ) {
231+ process . exit ( ) ;
232+ }
233+ engine . logger . info ( __ ( 'Waiting for after deploy to finish...' ) ) ;
234+ engine . logger . info ( __ ( 'You can exit with CTRL+C when after deploy completes' ) ) ;
229235 } ) ;
230236 }
231237
0 commit comments