Comparing version 1.0.1 to 1.0.2
81
index.js
@@ -11,3 +11,2 @@ /** | ||
_ = require('lodash'); | ||
var series = require('./series'), | ||
@@ -147,2 +146,7 @@ parallel = require('./parallel'); | ||
// Invalid runner type | ||
if (is.not.propertyDefined(this._runners, runnerType)) { | ||
throw new Error('The type ' + runnerType + ' is not a valid runner type'); | ||
} | ||
this._tasks[taskName] = task; | ||
@@ -200,14 +204,2 @@ this._tasksDepths[taskName] = depth; | ||
/** | ||
* Get the runner type for a specific task | ||
* | ||
* @param {String} taskName | ||
* @return {String} | ||
*/ | ||
Flowa.prototype._getTaskRunnerType = function(taskName) { | ||
return this._tasksRunnersTypes[taskName]; | ||
}; | ||
/** | ||
* Get the parent task name for a specific task | ||
@@ -227,4 +219,4 @@ * | ||
* | ||
* @param {String} taskName | ||
* @param {Function} callback called with (task, taskName) | ||
* @param {String} taskName | ||
* @param {Function} callback called with (task, taskName) | ||
*/ | ||
@@ -235,7 +227,2 @@ Flowa.prototype.forEachTask = function(taskName, callback) { | ||
// Not a compound task | ||
if (!this._isCompoundTask(taskName)) { | ||
return; | ||
} | ||
// Foreach sub task | ||
@@ -256,7 +243,14 @@ _.forIn(this._tasks[taskName], function(task, taskName) { | ||
/** | ||
* Log a specific task | ||
* Debug a specific task | ||
* | ||
* Calls the `debugCallback` with one string | ||
* argument in the format: `..TaskName`. | ||
* | ||
* Where `..` is repeated n times based on | ||
* the depth of the task. | ||
* | ||
* @param {String} taskName | ||
* @param {String} taskName | ||
* @param {Function} debugCallback | ||
*/ | ||
Flowa.prototype._log = function(taskName) { | ||
Flowa.prototype._debugTask = function(taskName, debugCallback) { | ||
@@ -273,3 +267,3 @@ // Is the root task | ||
console.log(_.repeat('..', this._tasksDepths[taskName] - 1) + taskName); | ||
debugCallback(_.repeat('..', this._tasksDepths[taskName] - 1) + taskName); | ||
@@ -291,20 +285,10 @@ }; | ||
// Timeout is exeeded | ||
if (runVariables.timedout) { | ||
return; | ||
} | ||
// Debugging is on | ||
if (runVariables.options.debug) { | ||
this._log(taskName); | ||
this._debugTask(taskName, runVariables.options.debugCallback); | ||
} | ||
// Is a single task | ||
// Is a compound task | ||
if (self._isCompoundTask(taskName)) { | ||
// Invalid runner type | ||
if (is.not.propertyDefined(self._runners, task.type)) { | ||
throw new Error('The type ' + task.type + ' is not a valid runner type'); | ||
} | ||
return self._runners[task.type](self, taskName, runVariables, callback); | ||
@@ -314,4 +298,12 @@ | ||
self._timeout(task, timeout, runVariables, taskName)(runVariables.context, callback); | ||
try { | ||
self._timeout(task, timeout, runVariables, taskName)(runVariables.context, callback); | ||
} catch (error) { | ||
callback(error); | ||
} | ||
}; | ||
@@ -398,13 +390,5 @@ | ||
try { | ||
// Execute the function | ||
asyncFunction.apply(null, args); | ||
// Execute the function | ||
asyncFunction.apply(null, args); | ||
} catch (error) { | ||
callbackWrapper(error); | ||
} | ||
}; | ||
@@ -436,3 +420,4 @@ | ||
taskTimeout: null, | ||
debug: false | ||
debug: false, | ||
debugCallback: console.log | ||
}); | ||
@@ -439,0 +424,0 @@ |
{ | ||
"name": "flowa", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Flow control for Node.js", | ||
@@ -10,2 +10,7 @@ "main": "index.js", | ||
}, | ||
"scripts": { | ||
"test": "nyc --reporter=text mocha ./test", | ||
"coverage": "nyc --reporter=html npm test && open coverage/index.html", | ||
"coveralls": "nyc report --reporter=text-lcov | coveralls" | ||
}, | ||
"keywords": [ | ||
@@ -46,3 +51,13 @@ "control", | ||
"lodash": "^4.17.10" | ||
}, | ||
"devDependencies": { | ||
"chai": "^4.1.2", | ||
"chai-as-promised": "^7.1.1", | ||
"coveralls": "^3.0.1", | ||
"mocha": "^5.2.0", | ||
"nyc": "^11.9.0", | ||
"require-dir": "^1.0.0", | ||
"sinon": "^6.1.0", | ||
"ticks-tracer": "^1.1.1" | ||
} | ||
} |
@@ -10,2 +10,4 @@ <p align="center"> | ||
[![Gitter](https://badges.gitter.im/join_chat.svg)](https://gitter.im/flowa-control-flow/Lobby) | ||
[![Build Status](https://travis-ci.org/faressoft/flowa.svg?branch=master)](https://travis-ci.org/faressoft/flowa) | ||
[![Coverage Status](https://coveralls.io/repos/github/faressoft/flowa/badge.svg?branch=master)](https://coveralls.io/github/faressoft/flowa?branch=master) | ||
@@ -16,3 +18,3 @@ > Flow control for Node.js | ||
Check a [suggested way](#use-it-with-express) to use `Flowa` with `Express.js`. | ||
Check the [suggested way](#use-it-with-express) to use `Flowa` with `Express.js`. | ||
@@ -232,18 +234,18 @@ # Table of Contents | ||
// Do task1 | ||
// Shorthand format for task1: task1 | ||
task1, | ||
// Do task2 | ||
// Shorthand format for task2:task2 | ||
task2, | ||
// Do task3 | ||
// Shorthand format for task3:task3 | ||
task3, | ||
// Do task4 | ||
// Shorthand format for task4:task4 | ||
task4, | ||
// Do task5 | ||
// Shorthand format for task5:task5 | ||
task5, | ||
// Do task6 | ||
// Shorthand format for task6:task6 | ||
task6 | ||
@@ -262,2 +264,4 @@ | ||
**Note**: No need to change the code, just add more services at the line 16. | ||
```js | ||
@@ -344,4 +348,4 @@ var express = require('express'); | ||
* | ||
* @param {Object} context | ||
* @param {Function} callback | ||
* @param {Object} context | ||
* @param {Function} callback | ||
*/ | ||
@@ -359,4 +363,4 @@ function incrementGreetingCounter(context, callback) { | ||
* | ||
* @param {Object} context | ||
* @param {Function} callback | ||
* @param {Object} context | ||
* @param {Function} callback | ||
*/ | ||
@@ -363,0 +367,0 @@ function generateGreetingMessage(context, callback) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
84304
36
2473
445
8
1