Skip to content

Commit 0ce13f5

Browse files
fix: replace processService with cleanupService
Replace processService with cleanupService where appropriate. The cleanupService allows execution of code after CLI has died. `processService` was used to handle some events, but it caused more issues than benefits. So remove it from the codebase.
1 parent 6028eae commit 0ce13f5

37 files changed

+53
-321
lines changed

lib/common/bootstrap.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ $injector.require("iOSEmulatorServices", "./mobile/ios/simulator/ios-emulator-se
8585
$injector.require("wp8EmulatorServices", "./mobile/wp8/wp8-emulator-services");
8686

8787
$injector.require("autoCompletionService", "./services/auto-completion-service");
88-
$injector.require("processService", "./services/process-service");
8988
$injector.requirePublic("settingsService", "./services/settings-service");
9089
$injector.require("opener", "./opener");
9190
$injector.require("microTemplateService", "./services/micro-templating-service");

lib/common/declarations.d.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,11 +1466,6 @@ interface INet {
14661466
waitForPortToListen(waitForPortListenData: IWaitForPortListenData): Promise<boolean>;
14671467
}
14681468

1469-
interface IProcessService {
1470-
listenersCount: number;
1471-
attachToProcessExitSignals(context: any, callback: () => void): void;
1472-
}
1473-
14741469
interface IDependencyInformation {
14751470
name: string;
14761471
version?: string;

lib/common/http-client.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,9 @@ export class HttpClient implements Server.IHttpClient {
1919
private cleanupData: ICleanupRequestData[];
2020

2121
constructor(private $logger: ILogger,
22-
private $processService: IProcessService,
2322
private $proxyService: IProxyService,
2423
private $staticConfig: Config.IStaticConfig) {
2524
this.cleanupData = [];
26-
this.$processService.attachToProcessExitSignals(this, () => {
27-
this.cleanupData.forEach(d => {
28-
this.cleanupAfterRequest(d);
29-
});
30-
});
3125
}
3226

3327
public async httpRequest(options: any, proxySettings?: IProxySettings): Promise<Server.IResponse> {

lib/common/mobile/android/logcat-helper.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export class LogcatHelper implements Mobile.ILogcatHelper {
1616
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
1717
private $logger: ILogger,
1818
private $injector: IInjector,
19-
private $processService: IProcessService,
2019
private $devicesService: Mobile.IDevicesService) {
2120
this.mapDevicesLoggingData = Object.create(null);
2221
}
@@ -53,8 +52,6 @@ export class LogcatHelper implements Mobile.ILogcatHelper {
5352
const lineText = line.toString();
5453
this.$deviceLogProvider.logData(lineText, this.$devicePlatformsConstants.Android, deviceIdentifier);
5554
});
56-
57-
this.$processService.attachToProcessExitSignals(this, logcatStream.kill);
5855
}
5956
}
6057

@@ -72,8 +69,6 @@ export class LogcatHelper implements Mobile.ILogcatHelper {
7269
logcatDumpStream.removeAllListeners();
7370
lineStream.removeAllListeners();
7471
});
75-
76-
this.$processService.attachToProcessExitSignals(this, logcatDumpStream.kill);
7772
}
7873

7974
/**

lib/common/mobile/ios/device/ios-device-operations.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,11 @@ export class IOSDeviceOperations extends EventEmitter implements IIOSDeviceOpera
99
public shouldDispose: boolean;
1010
private deviceLib: IOSDeviceLib.IOSDeviceLib;
1111

12-
constructor(private $logger: ILogger,
13-
private $processService: IProcessService) {
12+
constructor(private $logger: ILogger) {
1413
super();
1514

1615
this.isInitialized = false;
1716
this.shouldDispose = true;
18-
this.$processService.attachToProcessExitSignals(this, () => {
19-
this.setShouldDispose(true);
20-
this.dispose();
21-
});
2217
}
2318

2419
public async install(ipaPath: string, deviceIdentifiers: string[], errorHandler: DeviceOperationErrorHandler): Promise<IOSDeviceResponse> {

lib/common/mobile/ios/device/ios-device.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export class IOSDevice extends IOSDeviceBase {
2020
protected $deviceLogProvider: Mobile.IDeviceLogProvider,
2121
protected $lockService: ILockService,
2222
private $iOSSocketRequestExecutor: IiOSSocketRequestExecutor,
23-
protected $processService: IProcessService,
2423
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
2524
private $iOSDeviceProductNameMapper: Mobile.IiOSDeviceProductNameMapper,
2625
private $iosDeviceOperations: IIOSDeviceOperations,

lib/common/mobile/ios/ios-device-base.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export abstract class IOSDeviceBase implements Mobile.IiOSDevice {
66
protected abstract $errors: IErrors;
77
protected abstract $deviceLogProvider: Mobile.IDeviceLogProvider;
88
protected abstract $iOSDebuggerPortService: IIOSDebuggerPortService;
9-
protected abstract $processService: IProcessService;
109
protected abstract $lockService: ILockService;
1110
abstract deviceInfo: Mobile.IDeviceInfo;
1211
abstract applicationManager: Mobile.IDeviceApplicationManager;
@@ -33,8 +32,6 @@ export abstract class IOSDeviceBase implements Mobile.IiOSDevice {
3332
this.cachedSockets[appId].on("close", async () => {
3433
await this.destroyDebugSocket(appId);
3534
});
36-
37-
this.$processService.attachToProcessExitSignals(this, () => this.destroyDebugSocket(appId));
3835
}
3936

4037
return this.cachedSockets[appId];

lib/common/mobile/ios/simulator/ios-simulator-application-manager.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,10 @@ export class IOSSimulatorApplicationManager extends ApplicationManagerBase {
1515
private device: Mobile.IiOSDevice,
1616
private $options: IOptions,
1717
private $fs: IFileSystem,
18-
private $processService: IProcessService,
1918
private $deviceLogProvider: Mobile.IDeviceLogProvider,
2019
$logger: ILogger,
2120
$hooksService: IHooksService) {
2221
super($logger, $hooksService);
23-
this.$processService.attachToProcessExitSignals(this, () => {
24-
for (const appId in this._lldbProcesses) {
25-
/* tslint:disable:no-floating-promises */
26-
this.detachNativeDebugger(appId);
27-
/* tslint:enable:no-floating-promises */
28-
}
29-
});
3022
}
3123

3224
public async getInstalledApplications(): Promise<string[]> {

lib/common/mobile/ios/simulator/ios-simulator-device.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ export class IOSSimulator extends IOSDeviceBase implements Mobile.IiOSDevice {
2222
private $iOSEmulatorServices: Mobile.IiOSSimulatorService,
2323
private $iOSNotification: IiOSNotification,
2424
private $iOSSimulatorLogProvider: Mobile.IiOSSimulatorLogProvider,
25-
private $logger: ILogger,
26-
protected $processService: IProcessService) {
25+
private $logger: ILogger) {
2726
super();
2827
this.applicationManager = this.$injector.resolve(applicationManagerPath.IOSSimulatorApplicationManager, { iosSim: this.$iOSSimResolver.iOSSim, device: this });
2928
this.fileSystem = this.$injector.resolve(fileSystemPath.IOSSimulatorFileSystem, { iosSim: this.$iOSSimResolver.iOSSim });

lib/common/mobile/ios/simulator/ios-simulator-log-provider.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export class IOSSimulatorLogProvider extends EventEmitter implements Mobile.IiOS
88

99
constructor(private $iOSSimResolver: Mobile.IiOSSimResolver,
1010
private $logger: ILogger,
11-
private $processService: IProcessService,
1211
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
1312
private $deviceLogProvider: Mobile.IDeviceLogProvider) {
1413
super();
@@ -47,8 +46,6 @@ export class IOSSimulatorLogProvider extends EventEmitter implements Mobile.IiOS
4746
deviceLogChildProcess.stderr.on("data", action.bind(this));
4847
}
4948

50-
this.$processService.attachToProcessExitSignals(this, deviceLogChildProcess.kill);
51-
5249
this.simulatorsLoggingEnabled[deviceId] = true;
5350
this.simulatorsLogProcess[deviceId] = deviceLogChildProcess;
5451
}

0 commit comments

Comments
 (0)