Skip to content

Commit

Permalink
feat(base-package-manager): updated to keep track of child process
Browse files Browse the repository at this point in the history
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 Sep 3, 2019
1 parent 7aaa38e commit 3496c13
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/package-managers/base-package-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
14 changes: 6 additions & 8 deletions skeleton/webpack/aurelia_project/tasks/run.ext
Original file line number Diff line number Diff line change
Expand Up @@ -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.');

Expand All @@ -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();
});
}
});
}
});
};

Expand Down
1 change: 0 additions & 1 deletion skeleton/webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
"html-loader": "",
"istanbul-instrumenter-loader": "",
"webpack-bundle-analyzer": "",
"find-process": "^1.4.2",
"tree-kill": "^1.2.1",
},
"scripts": {
Expand Down

0 comments on commit 3496c13

Please sign in to comment.