Compare commits
56 Commits
Author | SHA1 | Date | |
---|---|---|---|
ada13619d0 | |||
9ae1a40260 | |||
e19184e29b | |||
36e02502d0 | |||
75219a5474 | |||
8f0ecb3f4a | |||
ec18663137 | |||
a476cf8c99 | |||
5af3185742 | |||
81849dc5eb | |||
51b9088d3e | |||
375b43a11c | |||
5b0a1edaa4 | |||
855e9b48c8 | |||
99db113285 | |||
844812311e | |||
555c696a8e | |||
879248f049 | |||
bb607eca9b | |||
f094f80531 | |||
71bdcce41d | |||
5a9cd96bed | |||
0f659ad60a | |||
395cb7d8a2 | |||
6284fa71d1 | |||
c5ec5fc0f9 | |||
17aa25fb61 | |||
6e55ed3162 | |||
ac9305c480 | |||
a51419f2b0 | |||
4b02d17d6d | |||
57350d6fee | |||
dcdf0059cc | |||
9cc9e15b04 | |||
6a19698617 | |||
bc53520869 | |||
752dec8fea | |||
ffc12d3fd5 | |||
0c0f0b78e1 | |||
3d01801df6 | |||
5355fd4e83 | |||
27a97c1bde | |||
c1f1500ffc | |||
e42c5004c2 | |||
e0c4a10411 | |||
6deab0541f | |||
22e3dc6136 | |||
e69e8df875 | |||
4cb24a4a6d | |||
ebac042791 | |||
d8fc992ba3 | |||
82def89388 | |||
4b832bbf95 | |||
cf8182b86a | |||
c708f964ec | |||
f9c4fb9887 |
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,6 +1,11 @@
|
||||
node_modules/
|
||||
.settings/
|
||||
.idea/
|
||||
coverage/
|
||||
docs/
|
||||
|
||||
ts/*.js
|
||||
ts/*.js.map
|
||||
ts/typings/
|
||||
test/result/
|
||||
|
||||
|
37
.gitlab-ci.yml
Normal file
37
.gitlab-ci.yml
Normal file
@ -0,0 +1,37 @@
|
||||
image: hosttoday/ht-docker-node:latest
|
||||
|
||||
stages:
|
||||
- test
|
||||
- release
|
||||
- page
|
||||
|
||||
testLEGACY:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test legacy
|
||||
tags:
|
||||
- docker
|
||||
|
||||
testLTS:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test lts
|
||||
tags:
|
||||
- docker
|
||||
|
||||
testSTABLE:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test stable
|
||||
tags:
|
||||
- docker
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci publish npm
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
5
.npmignore
Normal file
5
.npmignore
Normal file
@ -0,0 +1,5 @@
|
||||
ts/
|
||||
test/
|
||||
docs/
|
||||
coverage/
|
||||
node_modules/
|
15
.travis.yml
15
.travis.yml
@ -1,19 +1,14 @@
|
||||
language: node_js
|
||||
before_install:
|
||||
- nvm install stable
|
||||
- node -v
|
||||
- npm -v
|
||||
- npm install -g gulp
|
||||
- npm install gulp
|
||||
- npm install gulp-typescript
|
||||
node_js:
|
||||
- 4.2.4
|
||||
deploy:
|
||||
provider: npm
|
||||
email: npm@smart-coordination.com
|
||||
email: npm@lossless.digital
|
||||
api_key:
|
||||
secure: AcM6ooFjEIaWOC84QMxxugV3GtkMEoMI6zxy4oB9u9xihLopVZnm6c8FxIr+Wl2Ykjwj2deOuC7Q7QLtfH8/n4cVj1x7c32DJ21XJsE6uGm2opT7bSMm/NgcIvbkzWdPSyG8OpJEu8l///+YTceLdLV2Tn4lPobZRgu0KIF3Pg0Fo2V/0kSH/gSjlbLBgMBx1QrO2y52VHMdqWs3VwMIv1lEEicUsbnBg1z03I/Ka+JZQPCDYGgHu7y62zgB36mdkNVg8pyvGrrTSWeMVyHc8SSvBoqszVUeXfs4d4tcw0+vPsIJD5hDzAGOtH+3KO2Bgi87UB/Dgd5xw92+zQxhKnKewFiyTvANFXoag5UooPupWKhu5DljZ27CkgLX/N/AF6eTuQR0ffW92Bvz2YWis5JC75+HGFV2tBI7hRinScc00J0vOAqqVpp81PD6BXQDX2y5y77arArJVQTC5irOYL20x3UMBB7fOpTkYV9T2NxzR6OBv4P6MLWPbnmFr+zpjkzBxHeJMOosb+9W6TAbVmouM5SfnFU5bBYh2gF52Yz2FnfpDzclVZW/OI0YcAtIdozbHRcJ1s6pVkPqZIqKcCM+jVhzvt8NTnehSOqjFyIV9rcbsYQplLs8b9ntmcuRLCPatXMGFQM/y9Sjw4is0gHhRMjxQo32bfIiX1CTqVo=
|
||||
secure: TWN/oiICeNbAhGTbwf75FnKhXnIvyA66FhNF7C0jpjn2SChSgTANai87r0f9oU9ZP3307XdGHB+fTTCJnk3upNiBoWZnkV8skkAlseOY4mVzF9mS0ZEkxVR32FjJDWfqzv6hC+Y9qNDsGs2+Avsm6fQUOispLXYAk6VzSQC1HgIfyOJtIWT5LqEyXyT6oJIZ7xwt1CYcIeEpHUiAaPYsMEpwF5OBDFByVmNV38VdRGIBsoQd3lixso7/zOOgYvjR4b/onz5WzeWYlhzAuyzOnRGr1r/9eXAzzkYydvgFx3ix5OlrreKVFB6OtMpz4jmHdu9YDGT5bcvL2bSU2SGVQM5Bx8zZXkAxACQR8ZvWmPaWYAWCu9wrW5oovjqFUV0iR26z/sTABJqz4GaXf/vFcll2EdTfUT6xj2kCodfxljaudjPUF27FSt1UJBC7jQky08wHb6+onrE8WoQXteIE2oxtHWEGOlV/GAz0+q4ih0bdOSKfThmux0iEFmeF16sWH9UdL2jBBKuus+fBPdhA3V6uwYQtsCAurhquQLISkf7kT3KujdLS302bEbkut+D1Kd22IYA1J0wYd87th88TZHx7wgQyC+8lVHG+B1R20xGLxyHVEOfyZtChfBRdn53EcUiA2XriJbfiIym4dAMUtOg2iRJamHAL7jebQEUu7oA=
|
||||
on:
|
||||
tags: true
|
||||
repo: pushrocks/gulp-callfunction
|
||||
repo: pushrocks/gulp-function
|
||||
notifications:
|
||||
slack:
|
||||
secure: Bb8P3fboL52CugSsp0RhOkGCeWVbgjb+QDpnMHdSOa0Nequj8V4kvrzBLZOBOjaSB0/gMvdoB4Slv2bls1dAxXW1IX1DdRb3RLMKj/Owje7eTd4IoUuSs49y6/yEkVK+E1wicdwjlMmvsk8fQE/owDRMRXYoXxhN2ZOVSQvAQ3iBO0eokFvWO7yj/VSxKoITymCXA3LfyzXXUuhvxuQd3BPZCe25xa6GWuHtaa5fbJg17pp8jJX6VZYLSRcSYyJxMU8SLdkrOsQZKj0+/Yfpu7XTmPbqxjNapuE7Zm70mi+aB26IQCnmwkdcEQNJVxQOKoP2+/ZnDfcTLQROwH1PJVzol0hneH6DdOlWt9bvBJcUvFRwaDgIb5xXQV8bGsRe5ayE/4MgCgfvdBTvevu6n12fmPx74prIv4pOPMwlALjjP8XavGL4A6amOuV7fJiSyGAku8aUe1rlUXyfoHJswMyOfkIsvnGDE3eEfq1WUIjn8tW1ZozJyoCTAIh6IHPI3Nsg3LkTRvDHPYq25/xCKWxGb2OaJc3JeqVREqm0auDqj6HoVAi/mW/uyvwX9jEVX8fNoQ69ac5VUMFfn2Mx3sU6aHKgZe/tdrtql6NYtIA+g5/ZDnHE1mnbl6MfrYiKwRbrICH5v/u1xK+4+yh09BUqazi3PzOhyTRfba/gRUg=
|
||||
|
46
README.md
46
README.md
@ -1,25 +1,51 @@
|
||||
# gulp-callfunction
|
||||
# gulp-function
|
||||
accepts call to execute in gulp pipeline.
|
||||
|
||||
### build status/Dependencies
|
||||
[](https://travis-ci.org/pushrocks/gulp-callfunction)
|
||||
[](https://david-dm.org/pushrocks/gulp-callfunction)
|
||||
### Status
|
||||
[](https://travis-ci.org/pushrocks/gulp-function)
|
||||
[](https://david-dm.org/pushrocks/gulp-function)
|
||||
[](https://www.bithound.io/github/pushrocks/gulp-function/master/dependencies/npm)
|
||||
[](https://www.bithound.io/github/pushrocks/gulp-function)
|
||||
[](https://codecov.io/github/pushrocks/gulp-function?branch=master)
|
||||
|
||||
### Version
|
||||
[](https://badge.fury.io/gh/pushrocks%2Fgulp-function)
|
||||
[](https://badge.fury.io/js/gulp-function)
|
||||
|
||||
### Usage
|
||||
```javascript
|
||||
var gulp = require("gulp");
|
||||
var gulpCallFunction = require("gulp-callfunction");
|
||||
var gulpFunction = require("gulp-function");
|
||||
var Q = require("q");
|
||||
|
||||
var myFunction = function () {
|
||||
var done = Q.defer();
|
||||
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.src('./mydir/*.something')
|
||||
.pipe(gulpCallFunction(myFunction,'forEach'))
|
||||
.pipe(gulp.dest(./build/))
|
||||
var stream = gulp.src('./mydir/*.something')
|
||||
.pipe(gulpFunction(myFunction,'forEach')) //read the notes below
|
||||
.pipe(gulp.dest("./build/"));
|
||||
return stream; // by returning the stream gulp knows when our task has finished.
|
||||
});
|
||||
```
|
||||
|
||||
>Note: The first argument of gulpCallFunction can also be an array of multiple functionnames.
|
||||
>Note: the second argument can be empty (defaults to 'forEach') or 'atEnd'
|
||||
### Notes:
|
||||
|
||||
* 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.
|
||||
* The second argument can be empty, it defaults to "forEach"
|
||||
* The following options are available:
|
||||
* "forFirst" - executes when first chunk/vinylfile of the stream reaches the pipestop.
|
||||
file is pushed further down the line when function's returned promise is fullfilled.
|
||||
* "forEach" - executes like "forFirst" but with every chunk/vinylfile in the stream;
|
||||
* "atEnd" - executes after all chunks have passed and are processed in full.
|
||||
That means the stream's "finish" event fires **before "atLast" is executed**!!!
|
3
dist/gulpfunction.plugins.d.ts
vendored
Normal file
3
dist/gulpfunction.plugins.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import "typings-global";
|
||||
export declare let Q: any;
|
||||
export declare let through2: any;
|
6
dist/gulpfunction.plugins.js
vendored
Normal file
6
dist/gulpfunction.plugins.js
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
exports.Q = require("q");
|
||||
exports.through2 = require("through2");
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImd1bHBmdW5jdGlvbi5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFFYixTQUFDLEdBQUcsT0FBTyxDQUFDLEdBQUcsQ0FBQyxDQUFDO0FBQ2pCLGdCQUFRLEdBQUcsT0FBTyxDQUFDLFVBQVUsQ0FBQyxDQUFDIiwiZmlsZSI6Imd1bHBmdW5jdGlvbi5wbHVnaW5zLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFwidHlwaW5ncy1nbG9iYWxcIjtcclxuXHJcbmV4cG9ydCBsZXQgUSA9IHJlcXVpcmUoXCJxXCIpO1xyXG5leHBvcnQgbGV0IHRocm91Z2gyID0gcmVxdWlyZShcInRocm91Z2gyXCIpO1xyXG4iXX0=
|
1
dist/index.d.ts
vendored
Normal file
1
dist/index.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
import "typings-global";
|
64
dist/index.js
vendored
Normal file
64
dist/index.js
vendored
Normal file
File diff suppressed because one or more lines are too long
38
index.js
38
index.js
@ -1,38 +0,0 @@
|
||||
/// <reference path="typings/tsd.d.ts" />
|
||||
var through = require("through2");
|
||||
var path = require("path");
|
||||
var beautylog = require("beautylog");
|
||||
//important vars
|
||||
var executionMode; //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');
|
||||
}
|
||||
};
|
||||
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, executionMode) {
|
||||
if (executionMode === void 0) { executionMode = 'forEach'; }
|
||||
this.functionsToExecute = functionsToExecute;
|
||||
this.executionMode = executionMode;
|
||||
return through.obj(forEach, atEnd);
|
||||
};
|
@ -1,41 +0,0 @@
|
||||
0 info it worked if it ends with ok
|
||||
1 verbose cli [ '/usr/local/Cellar/node/4.1.0/bin/node',
|
||||
1 verbose cli '/usr/local/bin/npm',
|
||||
1 verbose cli 'version',
|
||||
1 verbose cli 'patch' ]
|
||||
2 info using npm@2.14.4
|
||||
3 info using node@v4.1.0
|
||||
4 info git [ 'status', '--porcelain' ]
|
||||
5 verbose stack Error: Git working directory not clean.
|
||||
5 verbose stack M README.md
|
||||
5 verbose stack M index.js
|
||||
5 verbose stack M package.json
|
||||
5 verbose stack M ts/index.ts
|
||||
5 verbose stack M ts/tsd.json
|
||||
5 verbose stack A ts/typings/colors/colors.d.ts
|
||||
5 verbose stack M ts/typings/tsd.d.ts
|
||||
5 verbose stack at /usr/local/lib/node_modules/npm/lib/version.js:171:21
|
||||
5 verbose stack at ChildProcess.exithandler (child_process.js:194:7)
|
||||
5 verbose stack at emitTwo (events.js:87:13)
|
||||
5 verbose stack at ChildProcess.emit (events.js:172:7)
|
||||
5 verbose stack at maybeClose (internal/child_process.js:817:16)
|
||||
5 verbose stack at Socket.<anonymous> (internal/child_process.js:319:11)
|
||||
5 verbose stack at emitOne (events.js:77:13)
|
||||
5 verbose stack at Socket.emit (events.js:169:7)
|
||||
5 verbose stack at Pipe._onclose (net.js:469:12)
|
||||
6 verbose cwd /Users/philippkunz/GitHub/pushrocks/gulp-callfunction
|
||||
7 error Darwin 15.0.0
|
||||
8 error argv "/usr/local/Cellar/node/4.1.0/bin/node" "/usr/local/bin/npm" "version" "patch"
|
||||
9 error node v4.1.0
|
||||
10 error npm v2.14.4
|
||||
11 error Git working directory not clean.
|
||||
11 error M README.md
|
||||
11 error M index.js
|
||||
11 error M package.json
|
||||
11 error M ts/index.ts
|
||||
11 error M ts/tsd.json
|
||||
11 error A ts/typings/colors/colors.d.ts
|
||||
11 error M ts/typings/tsd.d.ts
|
||||
12 error If you need help, you may report this error at:
|
||||
12 error <https://github.com/npm/npm/issues>
|
||||
13 verbose exit [ 1, true ]
|
4
npmts.json
Normal file
4
npmts.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"mode":"default",
|
||||
"coveralls":true
|
||||
}
|
35
package.json
35
package.json
@ -1,34 +1,37 @@
|
||||
{
|
||||
"name": "gulp-callfunction",
|
||||
"version": "0.0.3",
|
||||
"name": "gulp-function",
|
||||
"version": "1.3.3",
|
||||
"description": "accepts a function call as parameter to execute in gulp pipeline",
|
||||
"main": "index.js",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "(cd ts/compile && gulp)",
|
||||
"test": "(npmts)",
|
||||
"reinstall": "(rm -r node_modules && npm install)",
|
||||
"release": "(git pull origin master && npm version patch && git push origin master && git checkout release && git merge master && git push origin release && git checkout master)",
|
||||
"startdev": "(git checkout master && git pull origin master)"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pushrocks/gulp-callfunction.git"
|
||||
"url": "https://gitlab.com/pushrocks/gulp-function.git"
|
||||
},
|
||||
"keywords": [
|
||||
"json",
|
||||
"jade",
|
||||
"template"
|
||||
"gulpplugin",
|
||||
"gulp",
|
||||
"function"
|
||||
],
|
||||
"author": "Smart Coordination GmbH <office@push.rocks> (https://push.rocks)",
|
||||
"author": "Lossless GmbH <office@lossless.com> (https://lossless.com)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/pushrocks/gulp-callfunction/issues"
|
||||
},
|
||||
"homepage": "https://github.com/pushrocks/gulp-callfunction",
|
||||
"devDependencies": {
|
||||
"gulp": "^3.9.0",
|
||||
"gulp-typescript": "^2.9.2"
|
||||
"url": "https://gitlab.com/pushrocks/gulp-function/issues"
|
||||
},
|
||||
"homepage": "https://gitlab.com/pushrocks/gulp-function",
|
||||
"dependencies": {
|
||||
"beautylog": "0.0.15"
|
||||
"q": "^1.4.1",
|
||||
"through2": "^2.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"beautylog": "^5.0.8",
|
||||
"gulp": "^3.9.1",
|
||||
"npmts": "^5.2.1"
|
||||
}
|
||||
}
|
||||
|
2
test/README.md
Normal file
2
test/README.md
Normal file
@ -0,0 +1,2 @@
|
||||
#Test
|
||||
This directory contains files for testing
|
1
test/test.d.ts
vendored
Normal file
1
test/test.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
import "typings-test";
|
103
test/test.js
Normal file
103
test/test.js
Normal file
File diff suppressed because one or more lines are too long
1
test/test.js.map
Normal file
1
test/test.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,IAAI,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC3B,IAAI,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAC/C,IAAI,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AACrC,IAAI,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;AAErB,IAAI,UAAU,GAAG;IACb,IAAI,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,CAAA;IACpB,SAAS,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IACnC,IAAI,CAAC,OAAO,EAAE,CAAC;IACf,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;AACxB,CAAC,CAAC;AACF,IAAI,WAAW,GAAG;IACd,IAAI,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC;IACrB,SAAS,CAAC,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,iBAAiB,CAAC,CAAC;YAClC,IAAI,EAAE,CAAC;QACX,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
118
test/test.ts
Normal file
118
test/test.ts
Normal file
@ -0,0 +1,118 @@
|
||||
import "typings-test"
|
||||
var gulp = require("gulp");
|
||||
var gulpFunction = require("../dist/index.js");
|
||||
var beautylog = require("beautylog");
|
||||
var Q = require("q");
|
||||
|
||||
var myFunction = function () {
|
||||
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;
|
||||
};
|
||||
|
||||
var beforeFunction = function () {
|
||||
var done = Q.defer();
|
||||
beautylog.success("beforeFunction executed");
|
||||
done.resolve();
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
var middleFunctionRun = false;
|
||||
|
||||
var middleFunction = function () {
|
||||
var done = Q.defer();
|
||||
beautylog.success("middleFunction executed");
|
||||
setTimeout(function(){
|
||||
beautylog.log("timeout fired");
|
||||
middleFunctionRun = true;
|
||||
done.resolve();
|
||||
}, 500);
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
var afterFunction = function () {
|
||||
var done = Q.defer();
|
||||
beautylog.success("afterFunction executed");
|
||||
done.resolve();
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
let timeoutFunction = function(){
|
||||
var done = Q.defer();
|
||||
setTimeout(function(){
|
||||
beautylog.log("largeTimeout fired");
|
||||
done.resolve();
|
||||
},2000);
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
|
||||
|
||||
describe("gulpFunction",function(){
|
||||
it("should run through smoothly with " + "'forEach'".blue,function(done){
|
||||
gulp.src('./test/*.md')
|
||||
.pipe(gulpFunction(myFunction,'forEach'))
|
||||
.pipe(gulp.dest("./test/result/"));
|
||||
|
||||
gulp.src('./test/*.md')
|
||||
.pipe(gulpFunction([myFunction2,myFunction3],'forEach'))
|
||||
.pipe(gulp.dest("./test/result/"))
|
||||
.pipe(gulpFunction(done,"atEnd"));
|
||||
|
||||
});
|
||||
|
||||
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"));
|
||||
});
|
||||
|
||||
it("should run through smoothly once with " + "'atFirst'".blue,function(done){
|
||||
|
||||
gulp.src('./test/*.md')
|
||||
.pipe(gulpFunction([myFunction2,myFunction3],'forFirst'))
|
||||
.pipe(gulp.dest("./test/result/"))
|
||||
.pipe(gulpFunction(done,"atEnd"));
|
||||
});
|
||||
|
||||
it("should run in order",function(done){
|
||||
this.timeout(5000);
|
||||
let stream = gulp.src('./test/*.md')
|
||||
.pipe(gulpFunction([beforeFunction,middleFunction,middleFunction],'atEnd'))
|
||||
.pipe(gulpFunction(function(){
|
||||
beautylog.log("stream progressed");
|
||||
var done2 = Q.defer();
|
||||
done2.resolve();
|
||||
return done2.promise;
|
||||
},"forEach"))
|
||||
.pipe(gulpFunction(function(){
|
||||
beautylog.log("nextStep");
|
||||
}))
|
||||
.pipe(gulpFunction(afterFunction,"atEnd"))
|
||||
.pipe(gulpFunction(timeoutFunction,"atEnd"));
|
||||
|
||||
stream.on("finish",function(){
|
||||
beautylog.info("stream finished");
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
2
test/test01.md
Normal file
2
test/test01.md
Normal file
@ -0,0 +1,2 @@
|
||||
# Test.md
|
||||
This is a test file for the test.js gulp pipeline
|
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
|
@ -1,2 +0,0 @@
|
||||
nvm use v0.12.7
|
||||
gulp
|
@ -1,16 +0,0 @@
|
||||
// import gulp
|
||||
var gulp = require("gulp"),
|
||||
gulpTypescript = require("gulp-typescript");
|
||||
|
||||
gulp.task('compileTS', function() {
|
||||
var stream = gulp.src('../index.ts')
|
||||
.pipe(gulpTypescript({
|
||||
out: "index.js"
|
||||
}))
|
||||
.pipe(gulp.dest("../../"));
|
||||
return stream;
|
||||
});
|
||||
|
||||
gulp.task('default',['compileTS'], function() {
|
||||
console.log('Typescript compiled');
|
||||
});
|
@ -1,2 +0,0 @@
|
||||
# How to compile.
|
||||
Make sure gulp and gulp-taypescript from npm are available. Then run the gulpfile in this directory.
|
4
ts/gulpfunction.plugins.ts
Normal file
4
ts/gulpfunction.plugins.ts
Normal file
@ -0,0 +1,4 @@
|
||||
import "typings-global";
|
||||
|
||||
export let Q = require("q");
|
||||
export let through2 = require("through2");
|
88
ts/index.ts
88
ts/index.ts
@ -1,39 +1,65 @@
|
||||
/// <reference path="typings/tsd.d.ts" />
|
||||
var through = require("through2");
|
||||
var path = require("path");
|
||||
var beautylog = require("beautylog");
|
||||
import "typings-global";
|
||||
|
||||
//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();
|
||||
import plugins = require("./gulpfunction.plugins");
|
||||
|
||||
|
||||
|
||||
|
||||
module.exports = function (functionsToExecuteArg:any|any[],executionModeArg:string = 'forEach') {
|
||||
//important vars
|
||||
let executionMode = executionModeArg; //can be forEach or atEnd
|
||||
let functionsToExecute = functionsToExecuteArg;
|
||||
let promiseArray = [];
|
||||
let runFunction = function(functionArg){
|
||||
let returnValue = functionArg();
|
||||
if (typeof returnValue !== "undefined" && typeof returnValue.then !== "undefined") {
|
||||
promiseArray.push(returnValue);
|
||||
}
|
||||
} else {
|
||||
beautylog.error('gulp-callfunction: something is strange with the given arguments');
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
var forEach = function (file, enc, cb) {
|
||||
if (executionMode === 'forEach') {
|
||||
runFunctionNames();
|
||||
let checkAndRunFunction = function () {
|
||||
if (typeof functionsToExecute === "function" ) {
|
||||
runFunction(functionsToExecute);
|
||||
} else if (Array.isArray(functionsToExecute)) {
|
||||
for (let anyFunction in functionsToExecute) {
|
||||
runFunction(functionsToExecute[anyFunction]);
|
||||
}
|
||||
} else {
|
||||
throw new Error("gulp-callfunction: something is strange with the given arguments");
|
||||
}
|
||||
//tell gulp that we are complete
|
||||
return cb(null, file);
|
||||
};
|
||||
return plugins.Q.all(promiseArray);
|
||||
};
|
||||
|
||||
var atEnd = function() {
|
||||
let hasExecutedOnce = false;
|
||||
let forEach = function (file, enc, cb) { //the forEach function is called for every chunk
|
||||
switch (executionMode){
|
||||
case "forEach":
|
||||
checkAndRunFunction().then(function(){
|
||||
cb(null, file);
|
||||
});
|
||||
break;
|
||||
case "forFirst":
|
||||
!hasExecutedOnce ? checkAndRunFunction().then(function(){
|
||||
cb(null, file);
|
||||
}) : cb(null, file);
|
||||
hasExecutedOnce = true;
|
||||
break;
|
||||
case "atEnd":
|
||||
cb(null, file);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
let atEnd = function(cb) {
|
||||
if (executionMode === "atEnd") {
|
||||
runFunctionNames();
|
||||
checkAndRunFunction().then(function(){
|
||||
cb();
|
||||
});
|
||||
} else {
|
||||
cb();
|
||||
}
|
||||
};
|
||||
module.exports = function (functionsToExecute:any|any[],executionMode:string = 'forEach') {
|
||||
this.functionsToExecute = functionsToExecute;
|
||||
this.executionMode = executionMode;
|
||||
return through.obj(forEach,atEnd);
|
||||
};
|
||||
return plugins.through2.obj(forEach,atEnd);
|
||||
};
|
||||
|
123
ts/typings/colors/colors.d.ts
vendored
123
ts/typings/colors/colors.d.ts
vendored
@ -1,123 +0,0 @@
|
||||
// Type definitions for Colors.js 0.6.0-1
|
||||
// Project: https://github.com/Marak/colors.js
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module "colors" {
|
||||
interface Color {
|
||||
(text: string): string;
|
||||
|
||||
black: Color;
|
||||
red: Color;
|
||||
green: Color;
|
||||
yellow: Color;
|
||||
blue: Color;
|
||||
magenta: Color;
|
||||
cyan: Color;
|
||||
white: Color;
|
||||
gray: Color;
|
||||
grey: Color;
|
||||
|
||||
bgBlack: Color;
|
||||
bgRed: Color;
|
||||
bgGreen: Color;
|
||||
bgYellow: Color;
|
||||
bgBlue: Color;
|
||||
bgMagenta: Color;
|
||||
bgCyan: Color;
|
||||
bgWhite: Color;
|
||||
|
||||
reset: Color;
|
||||
bold: Color;
|
||||
dim: Color;
|
||||
italic: Color;
|
||||
underline: Color;
|
||||
inverse: Color;
|
||||
hidden: Color;
|
||||
strikethrough: Color;
|
||||
|
||||
rainbow: Color;
|
||||
zebra: Color;
|
||||
america: Color;
|
||||
trap: Color;
|
||||
random: Color;
|
||||
}
|
||||
|
||||
module e {
|
||||
export function setTheme(theme:any): void;
|
||||
|
||||
export var black: Color;
|
||||
export var red: Color;
|
||||
export var green: Color;
|
||||
export var yellow: Color;
|
||||
export var blue: Color;
|
||||
export var magenta: Color;
|
||||
export var cyan: Color;
|
||||
export var white: Color;
|
||||
export var gray: Color;
|
||||
export var grey: Color;
|
||||
|
||||
export var bgBlack: Color;
|
||||
export var bgRed: Color;
|
||||
export var bgGreen: Color;
|
||||
export var bgYellow: Color;
|
||||
export var bgBlue: Color;
|
||||
export var bgMagenta: Color;
|
||||
export var bgCyan: Color;
|
||||
export var bgWhite: Color;
|
||||
|
||||
export var reset: Color;
|
||||
export var bold: Color;
|
||||
export var dim: Color;
|
||||
export var italic: Color;
|
||||
export var underline: Color;
|
||||
export var inverse: Color;
|
||||
export var hidden: Color;
|
||||
export var strikethrough: Color;
|
||||
|
||||
export var rainbow: Color;
|
||||
export var zebra: Color;
|
||||
export var america: Color;
|
||||
export var trap: Color;
|
||||
export var random: Color;
|
||||
}
|
||||
|
||||
export = e;
|
||||
}
|
||||
|
||||
interface String {
|
||||
black: string;
|
||||
red: string;
|
||||
green: string;
|
||||
yellow: string;
|
||||
blue: string;
|
||||
magenta: string;
|
||||
cyan: string;
|
||||
white: string;
|
||||
gray: string;
|
||||
grey: string;
|
||||
|
||||
bgBlack: string;
|
||||
bgRed: string;
|
||||
bgGreen: string;
|
||||
bgYellow: string;
|
||||
bgBlue: string;
|
||||
bgMagenta: string;
|
||||
bgCyan: string;
|
||||
bgWhite: string;
|
||||
|
||||
reset: string;
|
||||
bold: string;
|
||||
dim: string;
|
||||
italic: string;
|
||||
underline: string;
|
||||
inverse: string;
|
||||
hidden: string;
|
||||
strikethrough: string;
|
||||
|
||||
rainbow: string;
|
||||
zebra: string;
|
||||
america: string;
|
||||
trap: string;
|
||||
random: string;
|
||||
}
|
2079
ts/typings/node/node.d.ts
vendored
2079
ts/typings/node/node.d.ts
vendored
File diff suppressed because it is too large
Load Diff
2
ts/typings/tsd.d.ts
vendored
2
ts/typings/tsd.d.ts
vendored
@ -1,2 +0,0 @@
|
||||
/// <reference path="node/node.d.ts" />
|
||||
/// <reference path="colors/colors.d.ts" />
|
Reference in New Issue
Block a user