mirror of https://github.com/embarklabs/embark.git
fix(@embark/core): move process.on inside ProcessWrapper's constructor
This avoids mistakenly placing process event handlers on the parent process whenever the `embark-core` package is loaded. Also, don't listen for an `'exit'` event on `process` and then call `process.exit(0)` since the event "is emitted after the child process ends" ([docs][docs]), i.e. it's unnecessary to do so and in any case it's not correct to always exit with code `0`. [docs]: https://nodejs.org/docs/latest-v10.x/api/child_process.html#child_process_event_exit
This commit is contained in:
parent
2eb5617443
commit
fd09488e4b
|
@ -1,11 +1,6 @@
|
|||
import { Events } from './eventsWrapper';
|
||||
const constants = require('../../constants');
|
||||
|
||||
process.on('uncaughtException', function(e) {
|
||||
process.send({error: e.stack});
|
||||
});
|
||||
|
||||
|
||||
export class ProcessWrapper {
|
||||
|
||||
/**
|
||||
|
@ -16,6 +11,9 @@ export class ProcessWrapper {
|
|||
* @param {Options} options pingParent: true by default
|
||||
*/
|
||||
constructor(options = {}) {
|
||||
process.on('uncaughtException', function(e) {
|
||||
process.send({error: e.stack});
|
||||
});
|
||||
this.options = Object.assign({pingParent: true}, options);
|
||||
this.interceptLogs();
|
||||
this.events = new Events();
|
||||
|
@ -83,7 +81,3 @@ export class ProcessWrapper {
|
|||
console.log('Process killed');
|
||||
}
|
||||
}
|
||||
|
||||
process.on('exit', () => {
|
||||
process.exit(0);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue