Comparing version 1.2.1 to 1.2.2
@@ -14,2 +14,5 @@ /** | ||
var self = this; | ||
var identity = this.identity; | ||
// If machine definition did not explicitly flag itself as synchronous, | ||
@@ -19,3 +22,3 @@ // prevent this usage. | ||
throw (function (){ | ||
var _err = new Error('Cannot use `.execSync()` with `'+this.identity+'` machine because it does not enable synchronous usage (i.e. `sync:true`)'); | ||
var _err = new Error('Cannot use `.execSync()` with `'+identity+'` machine because it does not enable synchronous usage (i.e. `sync:true`)'); | ||
_err.code = 'E_USAGE'; | ||
@@ -33,11 +36,36 @@ return _err; | ||
var isMachineActuallySynchronousCv = false; | ||
this.exec(function (_err, _result){ | ||
isMachineActuallySynchronousCv = true; | ||
err = _err; | ||
result = _result; | ||
var exitCallbacks = { | ||
success: function (_result){ | ||
isMachineActuallySynchronousCv = true; | ||
result = _result; | ||
}, | ||
error: function (_err){ | ||
isMachineActuallySynchronousCv = true; | ||
err = _err; | ||
} | ||
}; | ||
// Apply default exit | ||
exitCallbacks[this.defaultExit||'success'] = exitCallbacks.success; | ||
// Built exit callbacks for all other exits. | ||
_.each(this.exits, function (exitDef, exitName) { | ||
if (exitName === this.defaultExit || exitName === 'success') return; | ||
exitCallbacks[exitName] = function (_data){ | ||
isMachineActuallySynchronousCv = true; | ||
// ensure `_data` exists | ||
// (if not, built it using the exit definition) | ||
if (!_data) { | ||
_data = new Error(util.format('`%s` triggered its `%s` exit', self.identity, exitName) + ((self.exits[exitName] && self.exits[exitName].description)?': '+self.exits[exitName].description:'') + ''); | ||
} | ||
err = _data; | ||
}; | ||
}); | ||
this.exec(exitCallbacks); | ||
if (!isMachineActuallySynchronousCv) { | ||
throw (function (){ | ||
var _err = new Error('Cannot use `.execSync()` with `'+this.identity+'` machine because, although it declares synchronous usage (i.e. `sync:true`), it is not actually synchronous.'); | ||
var _err = new Error('Cannot use `.execSync()` with `'+identity+'` machine because, although it declares synchronous usage (i.e. `sync:true`), it is not actually synchronous.'); | ||
_err.code = 'E_MACHINE_INCONSISTENT'; | ||
@@ -44,0 +72,0 @@ return _err; |
@@ -30,3 +30,6 @@ /** | ||
if(val === undefined) { | ||
throw new Error('Undefined value'); | ||
var err = new Error(); | ||
err.code = 'E_UNDEFINED_VAL'; | ||
err.message = 'Undefined value'; | ||
throw err; | ||
} | ||
@@ -33,0 +36,0 @@ |
{ | ||
"name": "machine", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "Configure and execute machines", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
63400
1749