updated structure
This commit is contained in:
parent
e0c4a10411
commit
e42c5004c2
30
index.js
30
index.js
@ -2,13 +2,19 @@
|
||||
var through = require("through2");
|
||||
var path = require("path");
|
||||
var beautylog = require("beautylog")("os");
|
||||
//important vars
|
||||
var gulpCallFunction = {
|
||||
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
|
||||
};
|
||||
var runFunctionNames = function () {
|
||||
};
|
||||
gulpCallFunction.functionsToExecute = functionsToExecute;
|
||||
gulpCallFunction.executionMode = executionMode;
|
||||
gulpCallFunction.logBool = logBool;
|
||||
var runFunctionNames = function () {
|
||||
if (typeof gulpCallFunction.functionsToExecute == "function") {
|
||||
gulpCallFunction.functionsToExecute();
|
||||
}
|
||||
@ -20,8 +26,8 @@ var runFunctionNames = function () {
|
||||
else {
|
||||
beautylog.error('gulp-callfunction: something is strange with the given arguments');
|
||||
}
|
||||
};
|
||||
var forEach = function (file, enc, cb) {
|
||||
};
|
||||
var forEach = function (file, enc, cb) {
|
||||
if (gulpCallFunction.logBool)
|
||||
beautylog.log(gulpCallFunction.executionMode);
|
||||
if (gulpCallFunction.executionMode === 'forEach') {
|
||||
@ -31,18 +37,12 @@ var forEach = function (file, enc, cb) {
|
||||
}
|
||||
//tell gulp that we are complete
|
||||
return cb(null, file);
|
||||
};
|
||||
var atEnd = function (cb) {
|
||||
};
|
||||
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; }
|
||||
gulpCallFunction.functionsToExecute = functionsToExecute;
|
||||
gulpCallFunction.executionMode = executionMode;
|
||||
gulpCallFunction.logBool = logBool;
|
||||
};
|
||||
return through.obj(forEach, atEnd);
|
||||
};
|
||||
|
30
ts/index.ts
30
ts/index.ts
@ -3,14 +3,16 @@ 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 () {
|
||||
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)) {
|
||||
@ -20,10 +22,10 @@ var runFunctionNames = function () {
|
||||
} else {
|
||||
beautylog.error('gulp-callfunction: something is strange with the given arguments');
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
var forEach = function (file, enc, cb) {
|
||||
var forEach = function (file, enc, cb) {
|
||||
if (gulpCallFunction.logBool) beautylog.log(gulpCallFunction.executionMode);
|
||||
if (gulpCallFunction.executionMode === 'forEach') {
|
||||
if(gulpCallFunction.logBool) beautylog.log('is forEach');
|
||||
@ -31,17 +33,13 @@ var forEach = function (file, enc, cb) {
|
||||
}
|
||||
//tell gulp that we are complete
|
||||
return cb(null, file);
|
||||
};
|
||||
};
|
||||
|
||||
var atEnd = function(cb) {
|
||||
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;
|
||||
};
|
||||
return through.obj(forEach,atEnd);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user