diff --git a/index.js b/index.js index 0ddcb0f..1773468 100644 --- a/index.js +++ b/index.js @@ -2,47 +2,47 @@ var through = require("through2"); var path = require("path"); var beautylog = require("beautylog")("os"); -//important vars -var gulpCallFunction = { - executionMode: 'forEach', - functionsToExecute: undefined, - logBool: false -}; -var runFunctionNames = function () { - if (typeof gulpCallFunction.functionsToExecute == "function") { - gulpCallFunction.functionsToExecute(); - } - else if (Array.isArray(gulpCallFunction.functionsToExecute)) { - for (var anyFunction in gulpCallFunction.functionsToExecute) { - anyFunction(); - } - } - else { - beautylog.error('gulp-callfunction: something is strange with the given arguments'); - } -}; -var forEach = function (file, enc, cb) { - if (gulpCallFunction.logBool) - beautylog.log(gulpCallFunction.executionMode); - if (gulpCallFunction.executionMode === 'forEach') { - if (gulpCallFunction.logBool) - beautylog.log('is forEach'); - runFunctionNames(); - } - //tell gulp that we are complete - return cb(null, file); -}; -var atEnd = function (cb) { - if (gulpCallFunction.executionMode == "atEnd") { - runFunctionNames(); - } - cb(); -}; module.exports = function (functionsToExecute, executionMode, logBool) { if (executionMode === void 0) { executionMode = 'forEach'; } if (logBool === void 0) { logBool = false; } + //important vars + var gulpCallFunction = { + executionMode: 'forEach', + functionsToExecute: undefined, + logBool: false + }; gulpCallFunction.functionsToExecute = functionsToExecute; gulpCallFunction.executionMode = executionMode; gulpCallFunction.logBool = logBool; + var runFunctionNames = function () { + if (typeof gulpCallFunction.functionsToExecute == "function") { + gulpCallFunction.functionsToExecute(); + } + else if (Array.isArray(gulpCallFunction.functionsToExecute)) { + for (var anyFunction in gulpCallFunction.functionsToExecute) { + anyFunction(); + } + } + else { + beautylog.error('gulp-callfunction: something is strange with the given arguments'); + } + }; + var forEach = function (file, enc, cb) { + if (gulpCallFunction.logBool) + beautylog.log(gulpCallFunction.executionMode); + if (gulpCallFunction.executionMode === 'forEach') { + if (gulpCallFunction.logBool) + beautylog.log('is forEach'); + runFunctionNames(); + } + //tell gulp that we are complete + return cb(null, file); + }; + var atEnd = function (cb) { + if (gulpCallFunction.executionMode == "atEnd") { + runFunctionNames(); + } + cb(); + }; return through.obj(forEach, atEnd); }; diff --git a/ts/index.ts b/ts/index.ts index 460288a..127c57c 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -3,45 +3,43 @@ var through = require("through2"); var path = require("path"); var beautylog = require("beautylog")("os"); -//important vars -var gulpCallFunction = { - executionMode: 'forEach', //can be forEach or atEnd - functionsToExecute: undefined, - logBool: false -}; -var runFunctionNames = function () { - if (typeof gulpCallFunction.functionsToExecute == "function" ) { - gulpCallFunction.functionsToExecute(); - } else if (Array.isArray(gulpCallFunction.functionsToExecute)) { - for (var anyFunction in gulpCallFunction.functionsToExecute) { - anyFunction(); +module.exports = function (functionsToExecuteArg:any|any[],executionModeArg:string = 'forEach', logBoolArg = false) { + //important vars + var gulpCallFunction = { + executionMode: executionModeArg, //can be forEach or atEnd + functionsToExecute: functionsToExecuteArg, + logBool: logBoolArg + }; + + var runFunctionNames = function () { + if (typeof gulpCallFunction.functionsToExecute == "function" ) { + gulpCallFunction.functionsToExecute(); + } else if (Array.isArray(gulpCallFunction.functionsToExecute)) { + for (var anyFunction in gulpCallFunction.functionsToExecute) { + anyFunction(); + } + } else { + beautylog.error('gulp-callfunction: something is strange with the given arguments'); } - } else { - beautylog.error('gulp-callfunction: something is strange with the given arguments'); - } -}; + }; -var forEach = function (file, enc, cb) { - if (gulpCallFunction.logBool) beautylog.log(gulpCallFunction.executionMode); - if (gulpCallFunction.executionMode === 'forEach') { - if(gulpCallFunction.logBool) beautylog.log('is forEach'); - runFunctionNames(); - } - //tell gulp that we are complete - return cb(null, file); -}; + var forEach = function (file, enc, cb) { + if (gulpCallFunction.logBool) beautylog.log(gulpCallFunction.executionMode); + if (gulpCallFunction.executionMode === 'forEach') { + if(gulpCallFunction.logBool) beautylog.log('is forEach'); + runFunctionNames(); + } + //tell gulp that we are complete + return cb(null, file); + }; -var atEnd = function(cb) { - if (gulpCallFunction.executionMode == "atEnd") { - runFunctionNames(); - } - cb(); -}; -module.exports = function (functionsToExecute:any|any[],executionMode:string = 'forEach', logBool = false) { - gulpCallFunction.functionsToExecute = functionsToExecute; - gulpCallFunction.executionMode = executionMode; - gulpCallFunction.logBool = logBool; + var atEnd = function(cb) { + if (gulpCallFunction.executionMode == "atEnd") { + runFunctionNames(); + } + cb(); + }; return through.obj(forEach,atEnd); };