Skip to content
Permalink
Browse files

feat(base-package-manager): updated to keep track of child process

Keeping track of the child process in base-package-manager so that later on the process could be killed
  • Loading branch information...
shahabganji authored and 3cp committed Aug 21, 2019
1 parent 7aaa38e commit 3496c130f4ad24f9aadfe388a2671a1c2e9a47c5
@@ -12,7 +12,7 @@ exports.BasePackageManager = class {

run(command, args = [], workingDirectory = process.cwd()) {
return new Promise((resolve, reject) => {
spawn(
this.proc = spawn(
this.getExecutablePath(workingDirectory),
[command, ...args],
{ stdio: 'inherit', cwd: workingDirectory }
@@ -2,12 +2,13 @@ import { NPM } from 'aurelia-cli';
import { CLIOptions } from 'aurelia-cli';
import * as project from '../aurelia.json';

var find = require('find-process');
var kill = require('tree-kill');

const port = CLIOptions.getFlagValue('port') || project.platform.port;
const host = CLIOptions.getFlagValue('host') || project.platform.host || "localhost";

const npm = new NPM();

const run = () => {
console.log('`au run` is an alias of the `npm start`, you may use either of those; see README for more details.');

@@ -22,19 +23,16 @@ const run = () => {
args.push(host);
}

return (new NPM()).run('start', ['--', ...args]);
return npm.run('start', ['--', ...args]);
}

const shutdownAppServer = () => {
return new Promise(resolve => {
find('port', port)
.then(function (list) {
if (list.length) {
kill(list[0].pid, 'SIGKILL', function (err) {
if(npm.proc){
kill(npm.proc.pid, 'SIGKILL', function (err) {
resolve();
});
}
});
}
});
};

@@ -68,7 +68,6 @@
"html-loader": "",
"istanbul-instrumenter-loader": "",
"webpack-bundle-analyzer": "",
"find-process": "^1.4.2",
"tree-kill": "^1.2.1",
},
"scripts": {

0 comments on commit 3496c13

Please sign in to comment.
You can’t perform that action at this time.