Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
terminate(): void {
if (this.isPluginRunning) {
// tslint:disable-next-line:no-any
processTree(this.hostedInstanceProcess.pid, (err: Error, children: Array) => {
// tslint:disable-next-line:no-any
const args = ['-SIGTERM', this.hostedInstanceProcess.pid.toString()].concat(children.map((p: any) => p.PID));
cp.spawn('kill', args);
});
this.hostedPluginSupport.sendLog({ data: 'Hosted instance has been terminated', type: LogType.Info });
} else {
throw new Error('Hosted plugin instance is not running.');
}
}
protected unregisterWatchScript(path: string): void {
this.watchCompilationRegistry.delete(path);
this.hostedPluginSupport.sendLog({
data: 'Compilation watcher has been stopped in ' + path,
type: LogType.Info
});
}
protected runWatchScript(path: string): Promise {
const watchProcess = cp.spawn('yarn', ['run', 'watch'], { cwd: path });
watchProcess.on('exit', () => this.unregisterWatchScript(path));
this.watchCompilationRegistry.set(path, watchProcess);
this.hostedPluginSupport.sendLog({
data: 'Compilation watcher has been started in ' + path,
type: LogType.Info
});
return Promise.resolve();
}