Skip to content
Permalink
Browse files

feat(webpack): use: host & port && add: shutdownAppServer

  • Loading branch information...
shahabganji authored and 3cp committed Aug 16, 2019
1 parent b832ed1 commit d665ef196da39745d316e461f9d42cfef9d9c12c
Showing with 37 additions and 2 deletions.
  1. +35 −2 skeleton/webpack/aurelia_project/tasks/run.ext
  2. +2 −0 skeleton/webpack/package.json
@@ -1,8 +1,41 @@
import { NPM } from 'aurelia-cli';
import { CLIOptions } from 'aurelia-cli';
import * as project from '../aurelia.json';

export default function() {
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 run = () => {
console.log('`au run` is an alias of the `npm start`, you may use either of those; see README for more details.');

const args = process.argv.slice(3);
return (new NPM()).run('start',['--', ...args]);

if (!CLIOptions.hasFlag('port')) {
args.push('--port');
args.push(port);
}
if (!CLIOptions.hasFlag('host')) {
args.push('--host');
args.push(host);
}

return (new 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) {
resolve();
});
}
});
});
};

export { run as default, shutdownAppServer };
@@ -68,6 +68,8 @@
"html-loader": "",
"istanbul-instrumenter-loader": "",
"webpack-bundle-analyzer": "",
"find-process": "^1.4.2",
"tree-kill": "^1.2.1",
},
"scripts": {
"build": "webpack --env.production --env.extractCss",

0 comments on commit d665ef1

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