add better tests and coverage

This commit is contained in:
2016-02-12 05:36:23 +01:00
parent dcdf0059cc
commit 57350d6fee
10 changed files with 69 additions and 41 deletions

View File

@@ -4,20 +4,19 @@ var path = require("path");
var beautylog = require("beautylog");
module.exports = function (functionsToExecuteArg:any|any[],executionModeArg:string = 'forEach', logBoolArg = false) {
module.exports = function (functionsToExecuteArg:any|any[],executionModeArg:string = 'forEach') {
//important vars
var gulpFunction = {
executionMode: executionModeArg, //can be forEach or atEnd
functionsToExecute: functionsToExecuteArg,
logBool: logBoolArg
functionsToExecute: functionsToExecuteArg
};
var runFunctionNames = function () {
if (typeof gulpFunction.functionsToExecute == "function" ) {
if (typeof gulpFunction.functionsToExecute === "function" ) {
gulpFunction.functionsToExecute();
} else if (Array.isArray(gulpFunction.functionsToExecute)) {
for (var anyFunction in gulpFunction.functionsToExecute) {
anyFunction();
gulpFunction.functionsToExecute[anyFunction]();
}
} else {
beautylog.error('gulp-callfunction: something is strange with the given arguments');
@@ -26,9 +25,7 @@ module.exports = function (functionsToExecuteArg:any|any[],executionModeArg:stri
var forEach = function (file, enc, cb) {
if (gulpFunction.logBool) beautylog.log(gulpFunction.executionMode);
if (gulpFunction.executionMode === 'forEach') {
if(gulpFunction.logBool) beautylog.log('is forEach');
runFunctionNames();
}
//tell gulp that we are complete
@@ -36,7 +33,7 @@ module.exports = function (functionsToExecuteArg:any|any[],executionModeArg:stri
};
var atEnd = function(cb) {
if (gulpFunction.executionMode == "atEnd") {
if (gulpFunction.executionMode === "atEnd") {
runFunctionNames();
}
cb();