@@ -14,7 +14,8 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
14
14
public $hostInfo : IHostInfo ,
15
15
private $logger : ILogger ,
16
16
private $pluginsService : IPluginsService ,
17
- private $mobileHelper : Mobile . IMobileHelper
17
+ private $mobileHelper : Mobile . IMobileHelper ,
18
+ private $cleanupService : ICleanupService
18
19
) { super ( ) ; }
19
20
20
21
public async compileWithWatch ( platformData : IPlatformData , projectData : IProjectData , prepareData : IPrepareData ) : Promise < any > {
@@ -104,11 +105,15 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
104
105
} ) ;
105
106
}
106
107
107
- public stopWebpackCompiler ( platform : string ) : void {
108
+ public async stopWebpackCompiler ( platform : string ) : Promise < void > {
108
109
if ( platform ) {
109
- this . stopWebpackForPlatform ( platform ) ;
110
+ await this . stopWebpackForPlatform ( platform ) ;
110
111
} 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
+ }
112
117
}
113
118
}
114
119
@@ -139,6 +144,7 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
139
144
const childProcess = this . $childProcess . spawn ( "node" , args , { cwd : projectData . projectDir , stdio } ) ;
140
145
141
146
this . webpackProcesses [ platformData . platformNameLowerCase ] = childProcess ;
147
+ await this . $cleanupService . addKillProcess ( childProcess . pid . toString ( ) ) ;
142
148
143
149
return childProcess ;
144
150
}
@@ -233,9 +239,10 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
233
239
} ;
234
240
}
235
241
236
- private stopWebpackForPlatform ( platform : string ) {
242
+ private async stopWebpackForPlatform ( platform : string ) {
237
243
this . $logger . trace ( `Stopping webpack watch for platform ${ platform } .` ) ;
238
244
const webpackProcess = this . webpackProcesses [ platform ] ;
245
+ await this . $cleanupService . removeKillProcess ( webpackProcess . pid . toString ( ) ) ;
239
246
if ( webpackProcess ) {
240
247
webpackProcess . kill ( "SIGINT" ) ;
241
248
delete this . webpackProcesses [ platform ] ;
0 commit comments