@@ -14,7 +14,8 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
1414 public $hostInfo : IHostInfo ,
1515 private $logger : ILogger ,
1616 private $pluginsService : IPluginsService ,
17- private $mobileHelper : Mobile . IMobileHelper
17+ private $mobileHelper : Mobile . IMobileHelper ,
18+ private $cleanupService : ICleanupService
1819 ) { super ( ) ; }
1920
2021 public async compileWithWatch ( platformData : IPlatformData , projectData : IProjectData , prepareData : IPrepareData ) : Promise < any > {
@@ -104,11 +105,15 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
104105 } ) ;
105106 }
106107
107- public stopWebpackCompiler ( platform : string ) : void {
108+ public async stopWebpackCompiler ( platform : string ) : Promise < void > {
108109 if ( platform ) {
109- this . stopWebpackForPlatform ( platform ) ;
110+ await this . stopWebpackForPlatform ( platform ) ;
110111 } else {
111- Object . keys ( this . webpackProcesses ) . forEach ( pl => this . stopWebpackForPlatform ( pl ) ) ;
112+ const webpackedPlatforms = Object . keys ( this . webpackProcesses ) ;
113+
114+ for ( let i = 0 ; i < webpackedPlatforms . length ; i ++ ) {
115+ await this . stopWebpackForPlatform ( webpackedPlatforms [ i ] ) ;
116+ }
112117 }
113118 }
114119
@@ -139,6 +144,7 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
139144 const childProcess = this . $childProcess . spawn ( "node" , args , { cwd : projectData . projectDir , stdio } ) ;
140145
141146 this . webpackProcesses [ platformData . platformNameLowerCase ] = childProcess ;
147+ await this . $cleanupService . addKillProcess ( childProcess . pid . toString ( ) ) ;
142148
143149 return childProcess ;
144150 }
@@ -233,9 +239,10 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
233239 } ;
234240 }
235241
236- private stopWebpackForPlatform ( platform : string ) {
242+ private async stopWebpackForPlatform ( platform : string ) {
237243 this . $logger . trace ( `Stopping webpack watch for platform ${ platform } .` ) ;
238244 const webpackProcess = this . webpackProcesses [ platform ] ;
245+ await this . $cleanupService . removeKillProcess ( webpackProcess . pid . toString ( ) ) ;
239246 if ( webpackProcess ) {
240247 webpackProcess . kill ( "SIGINT" ) ;
241248 delete this . webpackProcesses [ platform ] ;
0 commit comments