Comparing version 0.7.3 to 0.7.4
{ | ||
"name": "cli-task", | ||
"version": "0.7.3", | ||
"version": "0.7.4", | ||
"repository": "https://github.com/astoilkov/cli-task", | ||
@@ -5,0 +5,0 @@ "description": "Task runner for developers minimalists", |
@@ -54,2 +54,5 @@ "use strict"; | ||
} | ||
else if (step.errorObject) { | ||
text += util_1.inspect(step.errorObject, { colors: true }); | ||
} | ||
if (step.child) { | ||
@@ -56,0 +59,0 @@ queue.push(...step.child.steps); |
@@ -30,2 +30,3 @@ import Task from './Task'; | ||
error: Error; | ||
errorObject: any; | ||
concurrent: boolean; | ||
@@ -38,3 +39,3 @@ errorMessage: string; | ||
success(): void; | ||
failure(err?: Error | string): void; | ||
failure(err?: string | Error | object): void; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const util_1 = require("util"); | ||
var StepStatus; | ||
@@ -29,6 +30,9 @@ (function (StepStatus) { | ||
} | ||
else if (err && typeof err.message == 'string') { | ||
else if (util_1.types.isNativeError(err)) { | ||
this.error = err; | ||
this.errorMessage = err.message; | ||
} | ||
else if (typeof err === 'object') { | ||
this.errorObject = err; | ||
} | ||
} | ||
@@ -35,0 +39,0 @@ } |
@@ -12,2 +12,3 @@ import { Step, IStepOptions, IStepState } from './Step'; | ||
run(): Promise<void>; | ||
private _errorOut; | ||
private _getCurrentStep; | ||
@@ -14,0 +15,0 @@ private _execTasks; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const util_1 = require("util"); | ||
const minimist = require("minimist"); | ||
@@ -11,13 +12,4 @@ const Renderer_1 = require("./Renderer"); | ||
this._stateValues = {}; | ||
let handleError = (err) => { | ||
if (this._getCurrentStep()) { | ||
this._getCurrentStep().failure(err); | ||
} | ||
else if (err) { | ||
throw err; | ||
} | ||
process.exit(1); | ||
}; | ||
process.on('uncaughtException', handleError); | ||
process.on('unhandledRejection', handleError); | ||
process.on('uncaughtException', (err) => this._errorOut(this._getCurrentStep(), err)); | ||
process.on('unhandledRejection', (message) => this._errorOut(this._getCurrentStep(), message)); | ||
} | ||
@@ -51,2 +43,11 @@ add(value) { | ||
} | ||
_errorOut(step, err) { | ||
process.exitCode = 1; | ||
if (step) { | ||
step.failure(err); | ||
} | ||
else if (util_1.types.isNativeError(err)) { | ||
throw err; | ||
} | ||
} | ||
_getCurrentStep() { | ||
@@ -84,3 +85,3 @@ let queue = this.steps.slice(); | ||
catch (err) { | ||
step.failure(err); | ||
this._errorOut(step, err); | ||
} | ||
@@ -95,3 +96,3 @@ } | ||
else if (result && result.then instanceof Function && result.catch instanceof Function) { | ||
result.then(done).catch((err) => step.failure(err)); | ||
result.then(done).catch((err) => this._errorOut(step, err)); | ||
} | ||
@@ -124,4 +125,3 @@ else if (step.child) { | ||
fail: (message) => { | ||
this._getCurrentStep().failure(message); | ||
process.exit(1); | ||
this._errorOut(this._getCurrentStep(), message); | ||
} | ||
@@ -128,0 +128,0 @@ }; |
16561
408