add better tests and coverage
This commit is contained in:
13
ts/index.ts
13
ts/index.ts
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user