Comparing version 1.0.2 to 1.1.0
{ | ||
"name": "task", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"main": "src/index.js", | ||
@@ -5,0 +5,0 @@ "bin": { |
const getFn = require('./util/get-fn') | ||
const DONE_COMPUTE = ['done', 'compute'] | ||
const DONE = ['done'] | ||
@@ -15,3 +17,7 @@ exports.props = { | ||
const afterall = (val, stamp, d) => { | ||
if (aftertasks.every(key => tasks.get([key, 'done', 'compute']))) { | ||
const alldone = aftertasks.every(key => Array.isArray(key) | ||
? tasks.get(key.concat(DONE_COMPUTE)) | ||
: tasks.get([key, 'done', 'compute']) | ||
) | ||
if (alldone) { | ||
if (fn) { | ||
@@ -25,3 +31,5 @@ task.set({ done: false }, false) | ||
aftertasks.forEach(key => { | ||
const done = tasks.get([key, 'done'], {}) | ||
const done = Array.isArray(key) | ||
? tasks.get(key.concat(DONE), {}) | ||
: tasks.get([key, 'done'], {}) | ||
done.on(afterall, after.path().join('.')) | ||
@@ -28,0 +36,0 @@ afterall(done.compute(), stamp) |
@@ -64,1 +64,31 @@ const test = require('tape') | ||
}) | ||
test('use after paths', { timeout: 500 }, t => { | ||
t.plan(1) | ||
ploy.get('tasks', {}).set({ | ||
bla: { | ||
tasks: { | ||
one: () => new Promise(resolve => resolve({ | ||
result: 'xxx', | ||
done: true | ||
})) | ||
} | ||
}, | ||
foo: { | ||
val: task => new Promise(resolve => resolve({ | ||
result: task.get('options', {}).serialize(true), | ||
done: true | ||
})), | ||
options: { | ||
val: [ '@', 'root', 'tasks', 'bla', 'tasks', 'one', 'result' ], | ||
$transform: val => val + '!' | ||
}, | ||
after: [ ['bla', 'tasks', 'one'] ] | ||
} | ||
}) | ||
ploy.get(['tasks', 'foo', 'result'], {}) | ||
.once(val => val.val === 'xxx!') | ||
.then(() => t.pass('correct output')) | ||
}) |
151674
1461