'use strict';

if (!global.Promise) {
    throw new Error('Native Promise implementation not found. You must use a newer version of Node.js or install a ES2015 Promise polyfill.');
}

class ChildProcessPromise extends Promise {
    constructor(executor) {
        var resolve;
        var reject;

        super((_resolve, _reject) => {
            resolve = _resolve;
            reject = _reject;

            if (executor) {
                executor(resolve, reject);
            }
        });

        this._cpResolve = resolve;
        this._cpReject = reject;
        this.childProcess = undefined;
    }

    progress(callback) {
        process.nextTick(() => {
            callback(this.childProcess);
        });

        return this;
    }

    then(onFulfilled, onRejected) {
        var newPromise = super.then(onFulfilled, onRejected);
        newPromise.childProcess = this.childProcess;
        return newPromise;
    }

    catch(onRejected) {
        var newPromise = super.catch(onRejected);
        newPromise.childProcess = this.childProcess;
        return newPromise;
    }

    done() {
        this.catch((e) => {
            process.nextTick(() => {
                console.log('UNCAUGHT ERROR');
                throw e;
            });
        });
    }
}

ChildProcessPromise.prototype.fail = ChildProcessPromise.prototype.catch;

module.exports = ChildProcessPromise;
'use strict';

if (!global.Promise) {
    throw new Error('Native Promise implementation not found. You must use a newer version of Node.js.');
}

class ChildProcessPromise extends Promise {
    constructor(executor) {
        var resolve;
        var reject;

        super((_resolve, _reject) => {
            resolve = _resolve;
            reject = _reject;

            if (executor) {
                executor(resolve, reject);
            }
        });

        this._cpResolve = resolve;
        this._cpReject = reject;
        this.childProcess = undefined;
    }

    progress(callback) {
        process.nextTick(() => {
            callback(this.childProcess);
        });

        return this;
    }

    then(onFulfilled, onRejected) {
        var newPromise = super.then(onFulfilled, onRejected);
        newPromise.childProcess = this.childProcess;
        return newPromise;
    }

    catch(onRejected) {
        var newPromise = super.catch(onRejected);
        newPromise.childProcess = this.childProcess;
        return newPromise;
    }

    done() {
        this.catch((e) => {
            process.nextTick(() => {
                console.log('UNCAUGHT ERROR');
                throw e;
            });
        });
    }
}

ChildProcessPromise.prototype.fail = ChildProcessPromise.prototype.catch;

module.exports = ChildProcessPromise;

Update ChildProcessPromise.js