Comparing version 0.0.2 to 0.0.6
10
index.js
@@ -64,4 +64,5 @@ var debug = require( 'debug')('workflow:common') | ||
var annotations = execute.annotations || build.annotations || WorkflowType.annotations; | ||
annotations && annotations.inject && annotations.inject.forEach(function(name) { | ||
annotations = annotations || {}; | ||
execute.inject && (annotations.inject = execute.inject); | ||
annotations.inject && annotations.inject.forEach(function(name) { | ||
var arg; | ||
@@ -93,3 +94,6 @@ switch(name[0]) { | ||
if (err) { | ||
console.error("Error in WF %s", workflowDefinition.task, err.message) | ||
if (!err.supressMessage) { | ||
console.error("Error in WF <%s>, error is:<%s> ", workflowDefinition.task, err.message || err) | ||
} | ||
return orig(err) | ||
} | ||
@@ -96,0 +100,0 @@ debug("completed") |
{ | ||
"name": "worksmith", | ||
"version": "0.0.2", | ||
"version": "0.0.6", | ||
"description": "A purely functional workflow engine ", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
var debug = require('debug')('workflow:activities:map') | ||
module.exports = function define(definition) { | ||
Object.keys(definition).forEach(function(key) { | ||
if (key[0] === ">") { | ||
definition.map = definition[key]; | ||
definition.resultTo = key.slice(1); | ||
delete definition[key] | ||
} | ||
}); | ||
return function build(context) { | ||
@@ -5,0 +13,0 @@ return function run(done) { |
@@ -160,2 +160,30 @@ var assert = require('assert') | ||
}) | ||
it("should handle inject shortcut ", function(done) { | ||
var flags = {}; | ||
var def = { | ||
task: function(def) { | ||
function build(context) { | ||
function execute(param1, done) { | ||
flags.param1 = param1; | ||
done(); | ||
} | ||
execute.inject = ["@field1"] | ||
return execute | ||
} | ||
return build | ||
} | ||
}; | ||
var wf = workflow(def) | ||
var context = { field1:"value1" }; | ||
var wi = wf(context); | ||
wi(function(err, res) { | ||
assert.equal(flags.param1,"value1", "injected must be passed correctly") | ||
done(); | ||
}) | ||
}) | ||
}) |
35120
30
781