Skip to content

Commit

Permalink
fix(@angular/cli): shut down after first Ctrl+C received
Browse files Browse the repository at this point in the history
  • Loading branch information
devoto13 committed Feb 20, 2018
1 parent 3be17e7 commit acb56de
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 21 deletions.
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@
"style-loader": "^0.19.1",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.1",
"tree-kill": "^1.0.0",
"typescript": "~2.6.2",
"uglifyjs-webpack-plugin": "^1.1.8",
"url-loader": "^0.6.2",
Expand Down Expand Up @@ -142,6 +141,7 @@
"tar": "^4.1.1",
"temp": "0.8.3",
"through": "^2.3.6",
"tree-kill": "^1.0.0",
"ts-node": "^4.1.0",
"tslint": "^5.8.0",
"zone.js": "^0.8.20"
Expand Down
1 change: 0 additions & 1 deletion packages/@ngtools/webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"npm": ">= 3.0.0"
},
"dependencies": {
"tree-kill": "^1.0.0",
"chalk": "~2.2.0",
"loader-utils": "^1.0.2",
"enhanced-resolve": "^3.1.0",
Expand Down
29 changes: 11 additions & 18 deletions packages/@ngtools/webpack/src/angular_compiler_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import * as path from 'path';
import * as ts from 'typescript';

const ContextElementDependency = require('webpack/lib/dependencies/ContextElementDependency');
const treeKill = require('tree-kill');

import { WebpackResourceLoader } from './resource_loader';
import { WebpackCompilerHost } from './compiler_host';
Expand Down Expand Up @@ -507,26 +506,20 @@ export class AngularCompilerPlugin implements Tapable {
forkOptions);

// Handle child process exit.
const handleChildProcessExit = () => {
this._killForkedTypeChecker();
const msg = 'AngularCompilerPlugin: Forked Type Checker exited unexpectedly. ' +
'Falling back to type checking on main thread.';
this._warnings.push(msg);
};
this._typeCheckerProcess.once('exit', handleChildProcessExit);
this._typeCheckerProcess.once('SIGINT', handleChildProcessExit);
this._typeCheckerProcess.once('uncaughtException', handleChildProcessExit);

// Handle parent process exit.
const handleParentProcessExit = () => this._killForkedTypeChecker();
process.once('exit', handleParentProcessExit);
process.once('SIGINT', handleParentProcessExit);
process.once('uncaughtException', handleParentProcessExit);
this._typeCheckerProcess.on('exit', (_, signal) => {
this._typeCheckerProcess = undefined;
this._forkTypeChecker = false;
if (signal !== 'SIGTERM') {
const msg = 'AngularCompilerPlugin: Forked Type Checker exited unexpectedly. ' +
'Falling back to type checking on main thread.';
this._warnings.push(msg);
}
});
}

private _killForkedTypeChecker() {
if (this._typeCheckerProcess && this._typeCheckerProcess.pid) {
treeKill(this._typeCheckerProcess.pid, 'SIGTERM');
if (this._typeCheckerProcess) {
this._typeCheckerProcess.kill('SIGTERM');
this._typeCheckerProcess = undefined;
this._forkTypeChecker = false;
}
Expand Down

0 comments on commit acb56de

Please sign in to comment.