added test
This commit is contained in:
@ -11,6 +11,16 @@ gulp.task('compileTS', function() {
|
||||
return stream;
|
||||
});
|
||||
|
||||
gulp.task('default',['compileTS'], function() {
|
||||
gulp.task('compileTestTS', function() {
|
||||
var stream = gulp.src('../test.ts')
|
||||
.pipe(gulpTypescript({
|
||||
out: "test.js"
|
||||
}))
|
||||
.pipe(gulp.dest("../../"));
|
||||
return stream;
|
||||
});
|
||||
|
||||
gulp.task('default',['compileTS','compileTestTS'], function() {
|
||||
console.log('Typescript compiled');
|
||||
});
|
||||
});
|
||||
gulp.start.apply(gulp, ['default']);
|
41
ts/index.ts
41
ts/index.ts
@ -4,13 +4,17 @@ var path = require("path");
|
||||
var beautylog = require("beautylog");
|
||||
|
||||
//important vars
|
||||
var executionMode:string; //can be forEach or atEnd
|
||||
var functionsToExecute;
|
||||
var gulpCallFunction = {
|
||||
executionMode: 'forEach', //can be forEach or atEnd
|
||||
functionsToExecute: undefined,
|
||||
logBool: false
|
||||
};
|
||||
|
||||
var runFunctionNames = function () {
|
||||
if (typeof functionsToExecute === "function" ) {
|
||||
functionsToExecute();
|
||||
} else if (Array.isArray(functionsToExecute)) {
|
||||
for (var anyFunction in functionsToExecute) {
|
||||
if (typeof gulpCallFunction.functionsToExecute == "function" ) {
|
||||
gulpCallFunction.functionsToExecute();
|
||||
} else if (Array.isArray(gulpCallFunction.functionsToExecute)) {
|
||||
for (var anyFunction in gulpCallFunction.functionsToExecute) {
|
||||
anyFunction();
|
||||
}
|
||||
} else {
|
||||
@ -20,20 +24,23 @@ var runFunctionNames = function () {
|
||||
|
||||
|
||||
var forEach = function (file, enc, cb) {
|
||||
if (executionMode === 'forEach') {
|
||||
runFunctionNames();
|
||||
}
|
||||
//tell gulp that we are complete
|
||||
return cb(null, file);
|
||||
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() {
|
||||
if (executionMode === "atEnd") {
|
||||
runFunctionNames();
|
||||
}
|
||||
if (gulpCallFunction.executionMode == "atEnd") {
|
||||
runFunctionNames();
|
||||
}
|
||||
};
|
||||
module.exports = function (functionsToExecute:any|any[],executionMode:string = 'forEach') {
|
||||
this.functionsToExecute = functionsToExecute;
|
||||
this.executionMode = executionMode;
|
||||
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);
|
||||
};
|
||||
|
14
ts/test.ts
Normal file
14
ts/test.ts
Normal file
@ -0,0 +1,14 @@
|
||||
/// <reference path="typings/tsd.d.ts" />
|
||||
var gulp = require("gulp");
|
||||
var gulpCallFunction = require("./index.js");
|
||||
|
||||
var myFunction = function () {
|
||||
console.log("Hello World!");
|
||||
}
|
||||
|
||||
gulp.task('default',function() {
|
||||
gulp.src('./test/test.md')
|
||||
.pipe(gulpCallFunction(myFunction,'forEach'))
|
||||
.pipe(gulp.dest("./test/result/"))
|
||||
});
|
||||
gulp.start.apply(gulp, ['default']);
|
Reference in New Issue
Block a user