now working

This commit is contained in:
Phil Kunz
2015-10-25 22:45:49 +01:00
parent b6a6c62962
commit 3930912f25
8 changed files with 260 additions and 17 deletions

View File

@@ -1,14 +1,39 @@
/// <reference path="typings/tsd.d.ts" />
var path, through;
var through = require("through2");
var path = require("path");
var beautylog = require("beautylog");
through = require("through2");
path = require("path");
//important vars
var executionMode:string; //can be forEach or atEnd
var functionsToExecute;
var runFunctionNames = function () {
if (typeof functionsToExecute === "function" ) {
functionsToExecute();
} else if (Array.isArray(functionsToExecute)) {
for (var anyFunction in functionsToExecute) {
anyFunction();
}
} else {
beautylog.error('gulp-callfunction: something is strange with the given arguments');
}
};
module.exports = (jsonObject,type = undefined) => {
return through.obj((file, enc, cb) => {
var forEach = function (file, enc, cb) {
if (executionMode === 'forEach') {
runFunctionNames();
}
//tell gulp that we are complete
return cb(null, file);
});
};
var atEnd = function() {
if (executionMode === "atEnd") {
runFunctionNames();
}
};
module.exports = function (functionsToExecute:any|any[],executionMode:string = 'forEach') {
this.functionsToExecute = functionsToExecute;
this.executionMode = executionMode;
return through.obj(forEach,atEnd);
};