Skip to content

Commit 19ac2db

Browse files
authored
Merge pull request #172 from NativeScript/iiivanov/stop-tns-process-on-extension-deactivation
Stop tns process on extension deactivation
2 parents 09769dd + 010ae22 commit 19ac2db

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
"dependencies": {
2828
"node-ipc": "8.10.3",
2929
"source-map": "0.6.1",
30-
"tree-kill": "^1.2.0",
3130
"universal-analytics": "0.4.13",
3231
"vscode-chrome-debug-core": "~3.9.0",
3332
"vscode-debugadapter": "1.26.0",

src/common/utilities.ts

+13
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import * as fs from 'fs';
1010
import * as url from 'url';
1111
import * as path from 'path';
1212
import {Version} from './version';
13+
import {ChildProcess, exec} from 'child_process';
1314

1415
export const enum Platform {
1516
Windows, OSX, Linux
@@ -380,4 +381,16 @@ export function getInstalledExtensionVersion(): Version {
380381

381382
export function getMinSupportedCliVersion(): Version {
382383
return Version.parse(require('../../package.json').minNativescriptCliVersion);
384+
}
385+
386+
export function killProcess(childProcess: ChildProcess) : void {
387+
switch (process.platform) {
388+
case "win32":
389+
exec(`taskkill /pid ${childProcess.pid} /T /F`);
390+
break;
391+
392+
default:
393+
childProcess.kill("SIGINT");
394+
break;
395+
}
383396
}

src/debug-adapter/webKitDebugAdapter.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {formatConsoleMessage} from './consoleHelper';
1616
import {Services} from '../services/debugAdapterServices';
1717
import {LoggerHandler, Handlers, Tags} from '../common/logger';
1818
import {DebugRequest} from './debugRequest';
19-
import * as kill from 'tree-kill';
2019

2120
interface IScopeVarHandle {
2221
objectId: string;
@@ -361,7 +360,7 @@ export class WebKitDebugAdapter implements DebugProtocol.IDebugAdapter {
361360
public disconnect(): Promise<void> {
362361
this.clearEverything();
363362
if (this._tnsProcess) {
364-
kill(this._tnsProcess.pid, 'SIGQUIT')
363+
utils.killProcess(this._tnsProcess);
365364
this._tnsProcess = null;
366365
}
367366
if (this._webKitConnection) {

src/main.ts

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {Services} from './services/extensionHostServices';
44
import {Project} from './project/project';
55
import {IosProject} from './project/iosProject';
66
import {AndroidProject} from './project/androidProject';
7+
import * as utils from './common/utilities';
78

89
// this method is called when the extension is activated
910
export function activate(context: vscode.ExtensionContext) {
@@ -56,6 +57,10 @@ export function activate(context: vscode.ExtensionContext) {
5657
tnsProcess.on('close', exitCode => {
5758
runChannel.hide();
5859
});
60+
61+
context.subscriptions.push({
62+
dispose: () => utils.killProcess(tnsProcess)
63+
});
5964
};
6065

6166
let runIosCommand = vscode.commands.registerCommand('nativescript.runIos', () => {

0 commit comments

Comments
 (0)