Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
395cb7d8a2 | |||
6284fa71d1 | |||
c5ec5fc0f9 | |||
17aa25fb61 | |||
6e55ed3162 | |||
ac9305c480 | |||
a51419f2b0 | |||
4b02d17d6d | |||
57350d6fee | |||
dcdf0059cc | |||
9cc9e15b04 | |||
6a19698617 | |||
bc53520869 | |||
752dec8fea | |||
ffc12d3fd5 | |||
0c0f0b78e1 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,6 +1,7 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
.settings/
|
.settings/
|
||||||
.idea/
|
.idea/
|
||||||
|
coverage/
|
||||||
|
|
||||||
ts/*.js
|
ts/*.js
|
||||||
ts/*.js.map
|
ts/*.js.map
|
||||||
|
15
.travis.yml
15
.travis.yml
@ -1,19 +1,14 @@
|
|||||||
language: node_js
|
language: node_js
|
||||||
before_install:
|
node_js:
|
||||||
- nvm install stable
|
- 4.2.4
|
||||||
- node -v
|
|
||||||
- npm -v
|
|
||||||
- npm install -g gulp
|
|
||||||
- npm install gulp
|
|
||||||
- npm install gulp-typescript
|
|
||||||
deploy:
|
deploy:
|
||||||
provider: npm
|
provider: npm
|
||||||
email: npm@smart-coordination.com
|
email: npm@lossless.digital
|
||||||
api_key:
|
api_key:
|
||||||
secure: ZgxvXgxlJlDDx4sv2H+M0Z36sZHDKEYRntudQWKLaDt1T2VojfsigNORrDZcHCs6FZo8t2Klsqte8PqDvAn7BxXIo5K86aaZOyulcHnmDQS6rBhJYHm01qJj2B+t03EozcsueYGcQIVyFLBnKl5Yj8GdQ6iVGbimHvgym/Bbo6pKQlKHvv7a+tOSmtRffeG4jZU454MYqc38ZPtKftdknk7m4T0wUP2l9Y1jKva8Zjd4+cw+xOhFAStkySrq8uNBEINN8e5vqvaOxq1d7V8evK7JQLjDtLOaj67cHJ3u7ZjHA2zk1j/Rs7X2jkeqqRbG1zhSHUjjqvnZRzC6ygswOHBBnSzF9P+tN7+jcNcn09PLsKh/HyXq/aRFKsNtvKjUey4cM27yt/LRLis70hrRTgR9EDZ/Q4Aoa/P/ObYf0XDE1rH08nngeASdmGFN+6n6idSq8C7IQ/YfmmQBhIhTSaNSGsYcG827fB5EZLoojCDOuNIrfyMOJHrSy14rgNWiGRj7C0md4yP7qGP53JPU9pPZLzRiD2/y9KuZ4qnE/edj9+POmVCr+uz2ILFQcTkEb9gItfMQGLd5m5MtPHgVFcoslU14O8o5WyFdG80xDHBvyy+1TsqnyRPwwlLwzepqZeUltZKXiOMDRIRurDRC1jtwcf8kJmWboio3GLIdQFU=
|
secure: TWN/oiICeNbAhGTbwf75FnKhXnIvyA66FhNF7C0jpjn2SChSgTANai87r0f9oU9ZP3307XdGHB+fTTCJnk3upNiBoWZnkV8skkAlseOY4mVzF9mS0ZEkxVR32FjJDWfqzv6hC+Y9qNDsGs2+Avsm6fQUOispLXYAk6VzSQC1HgIfyOJtIWT5LqEyXyT6oJIZ7xwt1CYcIeEpHUiAaPYsMEpwF5OBDFByVmNV38VdRGIBsoQd3lixso7/zOOgYvjR4b/onz5WzeWYlhzAuyzOnRGr1r/9eXAzzkYydvgFx3ix5OlrreKVFB6OtMpz4jmHdu9YDGT5bcvL2bSU2SGVQM5Bx8zZXkAxACQR8ZvWmPaWYAWCu9wrW5oovjqFUV0iR26z/sTABJqz4GaXf/vFcll2EdTfUT6xj2kCodfxljaudjPUF27FSt1UJBC7jQky08wHb6+onrE8WoQXteIE2oxtHWEGOlV/GAz0+q4ih0bdOSKfThmux0iEFmeF16sWH9UdL2jBBKuus+fBPdhA3V6uwYQtsCAurhquQLISkf7kT3KujdLS302bEbkut+D1Kd22IYA1J0wYd87th88TZHx7wgQyC+8lVHG+B1R20xGLxyHVEOfyZtChfBRdn53EcUiA2XriJbfiIym4dAMUtOg2iRJamHAL7jebQEUu7oA=
|
||||||
on:
|
on:
|
||||||
tags: true
|
tags: true
|
||||||
repo: pushrocks/gulp-callfunction
|
repo: pushrocks/gulp-function
|
||||||
notifications:
|
notifications:
|
||||||
slack:
|
slack:
|
||||||
secure: Bb8P3fboL52CugSsp0RhOkGCeWVbgjb+QDpnMHdSOa0Nequj8V4kvrzBLZOBOjaSB0/gMvdoB4Slv2bls1dAxXW1IX1DdRb3RLMKj/Owje7eTd4IoUuSs49y6/yEkVK+E1wicdwjlMmvsk8fQE/owDRMRXYoXxhN2ZOVSQvAQ3iBO0eokFvWO7yj/VSxKoITymCXA3LfyzXXUuhvxuQd3BPZCe25xa6GWuHtaa5fbJg17pp8jJX6VZYLSRcSYyJxMU8SLdkrOsQZKj0+/Yfpu7XTmPbqxjNapuE7Zm70mi+aB26IQCnmwkdcEQNJVxQOKoP2+/ZnDfcTLQROwH1PJVzol0hneH6DdOlWt9bvBJcUvFRwaDgIb5xXQV8bGsRe5ayE/4MgCgfvdBTvevu6n12fmPx74prIv4pOPMwlALjjP8XavGL4A6amOuV7fJiSyGAku8aUe1rlUXyfoHJswMyOfkIsvnGDE3eEfq1WUIjn8tW1ZozJyoCTAIh6IHPI3Nsg3LkTRvDHPYq25/xCKWxGb2OaJc3JeqVREqm0auDqj6HoVAi/mW/uyvwX9jEVX8fNoQ69ac5VUMFfn2Mx3sU6aHKgZe/tdrtql6NYtIA+g5/ZDnHE1mnbl6MfrYiKwRbrICH5v/u1xK+4+yh09BUqazi3PzOhyTRfba/gRUg=
|
secure: Bb8P3fboL52CugSsp0RhOkGCeWVbgjb+QDpnMHdSOa0Nequj8V4kvrzBLZOBOjaSB0/gMvdoB4Slv2bls1dAxXW1IX1DdRb3RLMKj/Owje7eTd4IoUuSs49y6/yEkVK+E1wicdwjlMmvsk8fQE/owDRMRXYoXxhN2ZOVSQvAQ3iBO0eokFvWO7yj/VSxKoITymCXA3LfyzXXUuhvxuQd3BPZCe25xa6GWuHtaa5fbJg17pp8jJX6VZYLSRcSYyJxMU8SLdkrOsQZKj0+/Yfpu7XTmPbqxjNapuE7Zm70mi+aB26IQCnmwkdcEQNJVxQOKoP2+/ZnDfcTLQROwH1PJVzol0hneH6DdOlWt9bvBJcUvFRwaDgIb5xXQV8bGsRe5ayE/4MgCgfvdBTvevu6n12fmPx74prIv4pOPMwlALjjP8XavGL4A6amOuV7fJiSyGAku8aUe1rlUXyfoHJswMyOfkIsvnGDE3eEfq1WUIjn8tW1ZozJyoCTAIh6IHPI3Nsg3LkTRvDHPYq25/xCKWxGb2OaJc3JeqVREqm0auDqj6HoVAi/mW/uyvwX9jEVX8fNoQ69ac5VUMFfn2Mx3sU6aHKgZe/tdrtql6NYtIA+g5/ZDnHE1mnbl6MfrYiKwRbrICH5v/u1xK+4+yh09BUqazi3PzOhyTRfba/gRUg=
|
||||||
|
21
README.md
21
README.md
@ -1,26 +1,39 @@
|
|||||||
# gulp-function
|
# gulp-function
|
||||||
accepts call to execute in gulp pipeline.
|
accepts call to execute in gulp pipeline.
|
||||||
|
|
||||||
### build status/Dependencies
|
### Status
|
||||||
[](https://travis-ci.org/pushrocks/gulp-function)
|
[](https://travis-ci.org/pushrocks/gulp-function)
|
||||||
[](https://david-dm.org/pushrocks/gulp-function)
|
[](https://david-dm.org/pushrocks/gulp-function)
|
||||||
[](https://david-dm.org/pushrocks/gulp-function#info=devDependencies)
|
[](https://david-dm.org/pushrocks/gulp-function#info=devDependencies)
|
||||||
|
[](https://www.bithound.io/github/pushrocks/gulp-function)
|
||||||
|
[](https://coveralls.io/github/pushrocks/gulp-function?branch=master)
|
||||||
|
|
||||||
### Usage
|
### Usage
|
||||||
```javascript
|
```javascript
|
||||||
var gulp = require("gulp");
|
var gulp = require("gulp");
|
||||||
var gulpFunction = require("gulp-function");
|
var gulpFunction = require("gulp-function");
|
||||||
|
var Q = require("q");
|
||||||
|
|
||||||
var myFunction = function () {
|
var myFunction = function () {
|
||||||
|
var done = Q.defer();
|
||||||
console.log("Hello World!")
|
console.log("Hello World!")
|
||||||
|
|
||||||
|
// NOTE:
|
||||||
|
// you can use done.resolve as callback function
|
||||||
|
// of any async tasks within this function
|
||||||
|
done.resolve();
|
||||||
|
|
||||||
|
return done.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
gulp.task('gulpTest',function() {
|
gulp.task('gulpTest',function() {
|
||||||
gulp.src('./mydir/*.something')
|
var stream = gulp.src('./mydir/*.something')
|
||||||
.pipe(gulpFunction(myFunction,'forEach'))
|
.pipe(gulpFunction(myFunction,'forEach')) //read the notes below
|
||||||
.pipe(gulp.dest("./build/"))
|
.pipe(gulp.dest("./build/"));
|
||||||
|
return stream; // by returning the stream gulp knows when our task has finished.
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
> Note: The first argument of gulpFunction can also be an array of multiple functionnames.
|
> Note: The first argument of gulpFunction can also be an array of multiple functionnames.
|
||||||
|
Each function can return a promise. the pipe stop will finish when every promise is fullfilled.
|
||||||
> Note: the second argument can be empty (defaults to 'forEach') or 'atEnd'
|
> Note: the second argument can be empty (defaults to 'forEach') or 'atEnd'
|
8
index.d.ts
vendored
8
index.d.ts
vendored
@ -1,4 +1,6 @@
|
|||||||
/// <reference path="ts/typings/main.d.ts" />
|
/// <reference path="ts/typings/main.d.ts" />
|
||||||
declare var through: any;
|
declare var plugins: {
|
||||||
declare var path: any;
|
beautylog: any;
|
||||||
declare var beautylog: any;
|
Q: any;
|
||||||
|
through: any;
|
||||||
|
};
|
||||||
|
68
index.js
68
index.js
@ -1,47 +1,57 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
/// <reference path="typings/main.d.ts" />
|
/// <reference path="typings/main.d.ts" />
|
||||||
var through = require("through2");
|
var plugins = {
|
||||||
var path = require("path");
|
beautylog: require("beautylog"),
|
||||||
var beautylog = require("beautylog");
|
Q: require("q"),
|
||||||
module.exports = function (functionsToExecuteArg, executionModeArg, logBoolArg) {
|
through: require("through2")
|
||||||
if (executionModeArg === void 0) { executionModeArg = 'forEach'; }
|
|
||||||
if (logBoolArg === void 0) { logBoolArg = false; }
|
|
||||||
//important vars
|
|
||||||
var gulpFunction = {
|
|
||||||
executionMode: executionModeArg,
|
|
||||||
functionsToExecute: functionsToExecuteArg,
|
|
||||||
logBool: logBoolArg
|
|
||||||
};
|
};
|
||||||
var runFunctionNames = function () {
|
module.exports = function (functionsToExecuteArg, executionModeArg) {
|
||||||
if (typeof gulpFunction.functionsToExecute == "function") {
|
if (executionModeArg === void 0) { executionModeArg = 'forEach'; }
|
||||||
gulpFunction.functionsToExecute();
|
//important vars
|
||||||
|
var executionMode = executionModeArg; //can be forEach or atEnd
|
||||||
|
var functionsToExecute = functionsToExecuteArg;
|
||||||
|
var promiseArray = [];
|
||||||
|
var runFunction = function (functionArg) {
|
||||||
|
var returnValue = functionArg();
|
||||||
|
if (typeof returnValue !== "undefined" && typeof returnValue.then !== "undefined") {
|
||||||
|
promiseArray.push(returnValue);
|
||||||
}
|
}
|
||||||
else if (Array.isArray(gulpFunction.functionsToExecute)) {
|
};
|
||||||
for (var anyFunction in gulpFunction.functionsToExecute) {
|
var checkAndRunFunction = function () {
|
||||||
anyFunction();
|
if (typeof functionsToExecute === "function") {
|
||||||
|
runFunction(functionsToExecute);
|
||||||
|
}
|
||||||
|
else if (Array.isArray(functionsToExecute)) {
|
||||||
|
for (var anyFunction in functionsToExecute) {
|
||||||
|
runFunction(functionsToExecute[anyFunction]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
beautylog.error('gulp-callfunction: something is strange with the given arguments');
|
plugins.beautylog.error('gulp-callfunction: something is strange with the given arguments');
|
||||||
}
|
}
|
||||||
|
return plugins.Q.all(promiseArray);
|
||||||
};
|
};
|
||||||
var forEach = function (file, enc, cb) {
|
var forEach = function (file, enc, cb) {
|
||||||
if (gulpFunction.logBool)
|
if (executionMode === 'forEach') {
|
||||||
beautylog.log(gulpFunction.executionMode);
|
checkAndRunFunction().then(function () {
|
||||||
if (gulpFunction.executionMode === 'forEach') {
|
cb(null, file);
|
||||||
if (gulpFunction.logBool)
|
});
|
||||||
beautylog.log('is forEach');
|
}
|
||||||
runFunctionNames();
|
else {
|
||||||
|
cb(null, file);
|
||||||
}
|
}
|
||||||
//tell gulp that we are complete
|
//tell gulp that we are complete
|
||||||
return cb(null, file);
|
|
||||||
};
|
};
|
||||||
var atEnd = function (cb) {
|
var atEnd = function (cb) {
|
||||||
if (gulpFunction.executionMode == "atEnd") {
|
if (executionMode === "atEnd") {
|
||||||
runFunctionNames();
|
checkAndRunFunction().then(function () {
|
||||||
}
|
|
||||||
cb();
|
cb();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cb();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
return through.obj(forEach, atEnd);
|
return plugins.through.obj(forEach, atEnd);
|
||||||
};
|
};
|
||||||
|
4
npmts.json
Normal file
4
npmts.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"mode":"default",
|
||||||
|
"coveralls":true
|
||||||
|
}
|
16
package.json
16
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "gulp-function",
|
"name": "gulp-function",
|
||||||
"version": "0.0.12",
|
"version": "1.1.1",
|
||||||
"description": "accepts a function call as parameter to execute in gulp pipeline",
|
"description": "accepts a function call as parameter to execute in gulp pipeline",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@ -14,9 +14,9 @@
|
|||||||
"url": "https://github.com/pushrocks/gulp-function.git"
|
"url": "https://github.com/pushrocks/gulp-function.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"json",
|
"gulpplugin",
|
||||||
"jade",
|
"gulp",
|
||||||
"template"
|
"function"
|
||||||
],
|
],
|
||||||
"author": "Smart Coordination GmbH <office@push.rocks> (https://push.rocks)",
|
"author": "Smart Coordination GmbH <office@push.rocks> (https://push.rocks)",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@ -25,10 +25,12 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/pushrocks/gulp-function",
|
"homepage": "https://github.com/pushrocks/gulp-function",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"beautylog": "2.0.4",
|
"beautylog": "^2.1.1",
|
||||||
"through2": "2.0.0"
|
"q": "^1.4.1",
|
||||||
|
"through2": "^2.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"gulp": "^3.9.0"
|
"gulp": "^3.9.1",
|
||||||
|
"npmts": "^2.2.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
8
test/test.d.ts
vendored
Normal file
8
test/test.d.ts
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/// <reference path="ts/typings/main.d.ts" />
|
||||||
|
declare var gulp: any;
|
||||||
|
declare var gulpFunction: any;
|
||||||
|
declare var beautylog: any;
|
||||||
|
declare var Q: any;
|
||||||
|
declare var myFunction: () => any;
|
||||||
|
declare var myFunction2: () => any;
|
||||||
|
declare var myFunction3: () => any;
|
38
test/test.js
38
test/test.js
@ -1,17 +1,45 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
/// <reference path="typings/main.d.ts" />
|
/// <reference path="typings/main.d.ts" />
|
||||||
var gulp = require("gulp");
|
var gulp = require("gulp");
|
||||||
var gulpFunction = require("../index.js");
|
var gulpFunction = require("../index.js");
|
||||||
var beautylog = require("beautylog");
|
var beautylog = require("beautylog");
|
||||||
|
var Q = require("q");
|
||||||
var myFunction = function () {
|
var myFunction = function () {
|
||||||
beautylog.log("Mocha Test successfull!");
|
var done = Q.defer();
|
||||||
|
beautylog.log("Function executed");
|
||||||
|
done.resolve();
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
var myFunction2 = function () {
|
||||||
|
var done = Q.defer();
|
||||||
|
beautylog.ok("Function2 executed");
|
||||||
|
done.resolve();
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
var myFunction3 = function () {
|
||||||
|
var done = Q.defer();
|
||||||
|
beautylog.success("Function3 executed");
|
||||||
|
done.resolve();
|
||||||
|
return done.promise;
|
||||||
};
|
};
|
||||||
describe("gulpFunction", function () {
|
describe("gulpFunction", function () {
|
||||||
it("should run through smoothly", function () {
|
it("should run through smoothly with " + "'forEach'".blue, function (done) {
|
||||||
gulp.task('default', function () {
|
gulp.src('./test/*.md')
|
||||||
gulp.src('./test/test.md')
|
|
||||||
.pipe(gulpFunction(myFunction, 'forEach'))
|
.pipe(gulpFunction(myFunction, 'forEach'))
|
||||||
.pipe(gulp.dest("./test/result/"));
|
.pipe(gulp.dest("./test/result/"));
|
||||||
|
gulp.src('./test/*.md')
|
||||||
|
.pipe(gulpFunction([myFunction2, myFunction3], 'forEach'))
|
||||||
|
.pipe(gulp.dest("./test/result/"))
|
||||||
|
.pipe(gulpFunction(done, "atEnd"));
|
||||||
});
|
});
|
||||||
gulp.start.apply(gulp, ['default']);
|
it("should run through smoothly with " + "'atEnd'".blue, function (done) {
|
||||||
|
gulp.src('./test/*.md')
|
||||||
|
.pipe(gulpFunction(myFunction, 'atEnd'))
|
||||||
|
.pipe(gulp.dest("./test/result/"));
|
||||||
|
gulp.src('./test/*.md')
|
||||||
|
.pipe(gulpFunction([myFunction2, myFunction3], 'atEnd'))
|
||||||
|
.pipe(gulp.dest("./test/result/"))
|
||||||
|
.pipe(gulpFunction(done, "atEnd"));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
2
test/test02.md
Normal file
2
test/test02.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# Test.md
|
||||||
|
This is another test file for the test.js gulp pipeline
|
63
ts/index.ts
63
ts/index.ts
@ -1,45 +1,60 @@
|
|||||||
/// <reference path="typings/main.d.ts" />
|
/// <reference path="typings/main.d.ts" />
|
||||||
var through = require("through2");
|
|
||||||
var path = require("path");
|
var plugins = {
|
||||||
var beautylog = require("beautylog");
|
beautylog: require("beautylog"),
|
||||||
|
Q: require("q"),
|
||||||
|
through: require("through2")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
module.exports = function (functionsToExecuteArg:any|any[],executionModeArg:string = 'forEach', logBoolArg = false) {
|
|
||||||
|
|
||||||
|
module.exports = function (functionsToExecuteArg:any|any[],executionModeArg:string = 'forEach') {
|
||||||
//important vars
|
//important vars
|
||||||
var gulpFunction = {
|
var executionMode = executionModeArg; //can be forEach or atEnd
|
||||||
executionMode: executionModeArg, //can be forEach or atEnd
|
var functionsToExecute = functionsToExecuteArg;
|
||||||
functionsToExecute: functionsToExecuteArg,
|
var promiseArray = [];
|
||||||
logBool: logBoolArg
|
var runFunction = function(functionArg){
|
||||||
|
var returnValue = functionArg();
|
||||||
|
if (typeof returnValue !== "undefined" && typeof returnValue.then !== "undefined") {
|
||||||
|
promiseArray.push(returnValue);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var runFunctionNames = function () {
|
var checkAndRunFunction = function () {
|
||||||
if (typeof gulpFunction.functionsToExecute == "function" ) {
|
if (typeof functionsToExecute === "function" ) {
|
||||||
gulpFunction.functionsToExecute();
|
runFunction(functionsToExecute);
|
||||||
} else if (Array.isArray(gulpFunction.functionsToExecute)) {
|
} else if (Array.isArray(functionsToExecute)) {
|
||||||
for (var anyFunction in gulpFunction.functionsToExecute) {
|
for (var anyFunction in functionsToExecute) {
|
||||||
anyFunction();
|
runFunction(functionsToExecute[anyFunction]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
beautylog.error('gulp-callfunction: something is strange with the given arguments');
|
plugins.beautylog.error('gulp-callfunction: something is strange with the given arguments');
|
||||||
}
|
}
|
||||||
|
return plugins.Q.all(promiseArray);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
var forEach = function (file, enc, cb) {
|
var forEach = function (file, enc, cb) {
|
||||||
if (gulpFunction.logBool) beautylog.log(gulpFunction.executionMode);
|
if (executionMode === 'forEach') {
|
||||||
if (gulpFunction.executionMode === 'forEach') {
|
checkAndRunFunction().then(function(){
|
||||||
if(gulpFunction.logBool) beautylog.log('is forEach');
|
cb(null, file);
|
||||||
runFunctionNames();
|
});
|
||||||
|
} else {
|
||||||
|
cb(null, file);
|
||||||
}
|
}
|
||||||
//tell gulp that we are complete
|
//tell gulp that we are complete
|
||||||
return cb(null, file);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var atEnd = function(cb) {
|
var atEnd = function(cb) {
|
||||||
if (gulpFunction.executionMode == "atEnd") {
|
if (executionMode === "atEnd") {
|
||||||
runFunctionNames();
|
checkAndRunFunction().then(function(){
|
||||||
}
|
|
||||||
cb();
|
cb();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
cb();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
return through.obj(forEach,atEnd);
|
return plugins.through.obj(forEach,atEnd);
|
||||||
};
|
};
|
||||||
|
40
ts/test.ts
40
ts/test.ts
@ -2,19 +2,49 @@
|
|||||||
var gulp = require("gulp");
|
var gulp = require("gulp");
|
||||||
var gulpFunction = require("../index.js");
|
var gulpFunction = require("../index.js");
|
||||||
var beautylog = require("beautylog");
|
var beautylog = require("beautylog");
|
||||||
|
var Q = require("q");
|
||||||
|
|
||||||
var myFunction = function () {
|
var myFunction = function () {
|
||||||
beautylog.log("Mocha Test successfull!");
|
var done = Q.defer()
|
||||||
|
beautylog.log("Function executed");
|
||||||
|
done.resolve();
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
var myFunction2 = function () {
|
||||||
|
var done = Q.defer();
|
||||||
|
beautylog.ok("Function2 executed");
|
||||||
|
done.resolve();
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
var myFunction3 = function () {
|
||||||
|
var done = Q.defer();
|
||||||
|
beautylog.success("Function3 executed");
|
||||||
|
done.resolve();
|
||||||
|
return done.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
describe("gulpFunction",function(){
|
describe("gulpFunction",function(){
|
||||||
it("should run through smoothly",function(){
|
it("should run through smoothly with " + "'forEach'".blue,function(done){
|
||||||
gulp.task('default',function() {
|
gulp.src('./test/*.md')
|
||||||
gulp.src('./test/test.md')
|
|
||||||
.pipe(gulpFunction(myFunction,'forEach'))
|
.pipe(gulpFunction(myFunction,'forEach'))
|
||||||
|
.pipe(gulp.dest("./test/result/"));
|
||||||
|
|
||||||
|
gulp.src('./test/*.md')
|
||||||
|
.pipe(gulpFunction([myFunction2,myFunction3],'forEach'))
|
||||||
.pipe(gulp.dest("./test/result/"))
|
.pipe(gulp.dest("./test/result/"))
|
||||||
|
.pipe(gulpFunction(done,"atEnd"));
|
||||||
|
|
||||||
});
|
});
|
||||||
gulp.start.apply(gulp, ['default']);
|
|
||||||
|
it("should run through smoothly with " + "'atEnd'".blue,function(done){
|
||||||
|
gulp.src('./test/*.md')
|
||||||
|
.pipe(gulpFunction(myFunction,'atEnd'))
|
||||||
|
.pipe(gulp.dest("./test/result/"));
|
||||||
|
|
||||||
|
gulp.src('./test/*.md')
|
||||||
|
.pipe(gulpFunction([myFunction2,myFunction3],'atEnd'))
|
||||||
|
.pipe(gulp.dest("./test/result/"))
|
||||||
|
.pipe(gulpFunction(done,"atEnd"));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user