now working
This commit is contained in:
39
ts/index.ts
39
ts/index.ts
@@ -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);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user