Compare commits
113 Commits
Author | SHA1 | Date | |
---|---|---|---|
a1fa6b751e | |||
5792a13b01 | |||
1008c3f103 | |||
c366bde211 | |||
e22c6764b7 | |||
50836eab06 | |||
077834f7a4 | |||
ca348b5475 | |||
2c9ab52cee | |||
7d35f4c90b | |||
a05253bdcd | |||
54b80098d2 | |||
c39a4a6cb0 | |||
f325479a11 | |||
c79f443c18 | |||
14bb4a90bb | |||
98a583bae1 | |||
848d9ac1e0 | |||
e7ccd9aec4 | |||
63bf7204dd | |||
a34a1b89fe | |||
f4455a9b91 | |||
1a01198d7f | |||
b3ec364a1d | |||
5d15c96511 | |||
f6e071156b | |||
63fe7c7423 | |||
c8dcdc0df4 | |||
743c7a03a5 | |||
f9e7bf450b | |||
b55a511fcb | |||
96c15cb90a | |||
0d772e8ab0 | |||
a324deb942 | |||
cb60bec110 | |||
291583b17a | |||
9d54da207f | |||
7aad993847 | |||
c208f04e23 | |||
54d8ef2576 | |||
8b891c74e4 | |||
1d8de68a66 | |||
a2b37a066d | |||
8a2c516274 | |||
e10c31c740 | |||
af68a92702 | |||
a8c3fa048a | |||
bea33fa29f | |||
739542bda1 | |||
63cf7091a1 | |||
04d7f9cf7e | |||
afc9fd122f | |||
a3dec7bb8a | |||
0e725c3fb4 | |||
6cd0ee78a3 | |||
b037dc99df | |||
27439d84cd | |||
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 |
26
.gitignore
vendored
26
.gitignore
vendored
@ -1,6 +1,22 @@
|
|||||||
node_modules/
|
.nogit/
|
||||||
.settings/
|
|
||||||
.idea/
|
|
||||||
|
|
||||||
ts/*.js
|
# artifacts
|
||||||
ts/*.js.map
|
coverage/
|
||||||
|
public/
|
||||||
|
pages/
|
||||||
|
|
||||||
|
# installs
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# caches
|
||||||
|
.yarn/
|
||||||
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
|
dist/
|
||||||
|
dist_web/
|
||||||
|
dist_serve/
|
||||||
|
dist_ts_web/
|
||||||
|
|
||||||
|
# custom
|
126
.gitlab-ci.yml
Normal file
126
.gitlab-ci.yml
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
# gitzone ci_default
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
|
cache:
|
||||||
|
paths:
|
||||||
|
- .npmci_cache/
|
||||||
|
key: '$CI_BUILD_STAGE'
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- security
|
||||||
|
- test
|
||||||
|
- release
|
||||||
|
- metadata
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# security stage
|
||||||
|
# ====================
|
||||||
|
mirror:
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci git mirror
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
snyk:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:snyk
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci command npm install --ignore-scripts
|
||||||
|
- npmci command snyk test
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# test stage
|
||||||
|
# ====================
|
||||||
|
|
||||||
|
testStable:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
|
testBuild:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command npm run build
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
release:
|
||||||
|
stage: release
|
||||||
|
script:
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm publish
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# metadata stage
|
||||||
|
# ====================
|
||||||
|
codequality:
|
||||||
|
stage: metadata
|
||||||
|
allow_failure: true
|
||||||
|
script:
|
||||||
|
- npmci command npm install -g tslint typescript
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
stage: metadata
|
||||||
|
script:
|
||||||
|
- npmci trigger
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
pages:
|
||||||
|
stage: metadata
|
||||||
|
script:
|
||||||
|
- npmci node install lts
|
||||||
|
- npmci command npm install -g @gitzone/tsdoc
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command tsdoc
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
artifacts:
|
||||||
|
expire_in: 1 week
|
||||||
|
paths:
|
||||||
|
- public
|
||||||
|
allow_failure: true
|
5
.npmignore
Normal file
5
.npmignore
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
ts/
|
||||||
|
test/
|
||||||
|
docs/
|
||||||
|
coverage/
|
||||||
|
node_modules/
|
19
.travis.yml
19
.travis.yml
@ -1,19 +0,0 @@
|
|||||||
language: node_js
|
|
||||||
before_install:
|
|
||||||
- nvm install stable
|
|
||||||
- node -v
|
|
||||||
- npm -v
|
|
||||||
- npm install -g gulp
|
|
||||||
- npm install gulp
|
|
||||||
- npm install gulp-typescript
|
|
||||||
deploy:
|
|
||||||
provider: npm
|
|
||||||
email: npm@smart-coordination.com
|
|
||||||
api_key:
|
|
||||||
secure: AcM6ooFjEIaWOC84QMxxugV3GtkMEoMI6zxy4oB9u9xihLopVZnm6c8FxIr+Wl2Ykjwj2deOuC7Q7QLtfH8/n4cVj1x7c32DJ21XJsE6uGm2opT7bSMm/NgcIvbkzWdPSyG8OpJEu8l///+YTceLdLV2Tn4lPobZRgu0KIF3Pg0Fo2V/0kSH/gSjlbLBgMBx1QrO2y52VHMdqWs3VwMIv1lEEicUsbnBg1z03I/Ka+JZQPCDYGgHu7y62zgB36mdkNVg8pyvGrrTSWeMVyHc8SSvBoqszVUeXfs4d4tcw0+vPsIJD5hDzAGOtH+3KO2Bgi87UB/Dgd5xw92+zQxhKnKewFiyTvANFXoag5UooPupWKhu5DljZ27CkgLX/N/AF6eTuQR0ffW92Bvz2YWis5JC75+HGFV2tBI7hRinScc00J0vOAqqVpp81PD6BXQDX2y5y77arArJVQTC5irOYL20x3UMBB7fOpTkYV9T2NxzR6OBv4P6MLWPbnmFr+zpjkzBxHeJMOosb+9W6TAbVmouM5SfnFU5bBYh2gF52Yz2FnfpDzclVZW/OI0YcAtIdozbHRcJ1s6pVkPqZIqKcCM+jVhzvt8NTnehSOqjFyIV9rcbsYQplLs8b9ntmcuRLCPatXMGFQM/y9Sjw4is0gHhRMjxQo32bfIiX1CTqVo=
|
|
||||||
on:
|
|
||||||
tags: true
|
|
||||||
repo: pushrocks/gulp-callfunction
|
|
||||||
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=
|
|
@ -1,6 +1,6 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2015 Push.Rocks
|
Copyright (c) 2015 Lossless GmbH
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
25
README.md
25
README.md
@ -1,25 +0,0 @@
|
|||||||
# gulp-callfunction
|
|
||||||
accepts call to execute in gulp pipeline.
|
|
||||||
|
|
||||||
### build status/Dependencies
|
|
||||||
[](https://travis-ci.org/pushrocks/gulp-callfunction)
|
|
||||||
[](https://david-dm.org/pushrocks/gulp-callfunction)
|
|
||||||
|
|
||||||
### Usage
|
|
||||||
```javascript
|
|
||||||
var gulp = require("gulp");
|
|
||||||
var gulpCallFunction = require("gulp-callfunction");
|
|
||||||
|
|
||||||
var myFunction = function () {
|
|
||||||
console.log("Hello World!")
|
|
||||||
}
|
|
||||||
|
|
||||||
gulp.task('gulpTest',function() {
|
|
||||||
gulp.src('./mydir/*.something')
|
|
||||||
.pipe(gulpCallFunction(myFunction,'forEach'))
|
|
||||||
.pipe(gulp.dest(./build/))
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
>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'
|
|
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 ]
|
|
19
npmextra.json
Normal file
19
npmextra.json
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"npmts": {
|
||||||
|
"mode": "default"
|
||||||
|
},
|
||||||
|
"npmci": {
|
||||||
|
"npmGlobalTools": [],
|
||||||
|
"npmAccessLevel": "public"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"module": {
|
||||||
|
"githost": "gitlab.com",
|
||||||
|
"gitscope": "pushrocks",
|
||||||
|
"gitrepo": "gulp-function",
|
||||||
|
"shortDescription": "accepts a function call as parameter to execute in gulp pipeline",
|
||||||
|
"npmPackagename": "@pushrocks/gulp-function",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
5454
package-lock.json
generated
Normal file
5454
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
59
package.json
59
package.json
@ -1,34 +1,53 @@
|
|||||||
{
|
{
|
||||||
"name": "gulp-callfunction",
|
"name": "@pushrocks/gulp-function",
|
||||||
"version": "0.0.3",
|
"private": false,
|
||||||
|
"version": "3.0.2",
|
||||||
"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": "dist/index.js",
|
||||||
|
"typings": "dist/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(cd ts/compile && gulp)",
|
"test": "(tstest test/)",
|
||||||
"reinstall": "(rm -r node_modules && npm install)",
|
"build": "(tsbuild)"
|
||||||
"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": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/pushrocks/gulp-callfunction.git"
|
"url": "https://gitlab.com/pushrocks/gulp-function.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"json",
|
"gulpplugin",
|
||||||
"jade",
|
"gulp",
|
||||||
"template"
|
"function",
|
||||||
|
"pushrocks"
|
||||||
],
|
],
|
||||||
"author": "Smart Coordination GmbH <office@push.rocks> (https://push.rocks)",
|
"author": "Lossless GmbH <office@lossless.com> (https://lossless.com)",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/pushrocks/gulp-callfunction/issues"
|
"url": "https://gitlab.com/pushrocks/gulp-function/issues"
|
||||||
},
|
|
||||||
"homepage": "https://github.com/pushrocks/gulp-callfunction",
|
|
||||||
"devDependencies": {
|
|
||||||
"gulp": "^3.9.0",
|
|
||||||
"gulp-typescript": "^2.9.2"
|
|
||||||
},
|
},
|
||||||
|
"homepage": "https://gitlab.com/pushrocks/gulp-function",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"beautylog": "0.0.15"
|
"@pushrocks/smartpromise": "^3.0.6",
|
||||||
}
|
"@types/through2": "^2.0.32",
|
||||||
|
"through2": "^3.0.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@gitzone/tsbuild": "^2.1.17",
|
||||||
|
"@gitzone/tstest": "^1.0.28",
|
||||||
|
"@pushrocks/smartgulp": "^2.0.2",
|
||||||
|
"@pushrocks/tapbundle": "^3.2.0",
|
||||||
|
"gulp": "^4.0.2",
|
||||||
|
"tslint": "^5.20.1",
|
||||||
|
"tslint-config-prettier": "^1.18.0"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"ts/**/*",
|
||||||
|
"ts_web/**/*",
|
||||||
|
"dist/**/*",
|
||||||
|
"dist_web/**/*",
|
||||||
|
"dist_ts_web/**/*",
|
||||||
|
"assets/**/*",
|
||||||
|
"cli.js",
|
||||||
|
"npmextra.json",
|
||||||
|
"readme.md"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
2
test/README.md
Normal file
2
test/README.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#Test
|
||||||
|
This directory contains files for testing
|
35
test/test.ts
Normal file
35
test/test.ts
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
import { expect, tap } from '@pushrocks/tapbundle';
|
||||||
|
|
||||||
|
import * as smartgulp from '@pushrocks/smartgulp';
|
||||||
|
let gulp = require('gulp');
|
||||||
|
import * as gulpFunction from '../ts/index';
|
||||||
|
|
||||||
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
|
|
||||||
|
tap.test('should run through smoothly with ' + "'forEach'", async tools => {
|
||||||
|
let done = smartpromise.defer();
|
||||||
|
let counter = 0;
|
||||||
|
gulp.src('./test/testfiles/*.md').pipe(
|
||||||
|
gulpFunction.forEach(async () => {
|
||||||
|
counter++;
|
||||||
|
if (counter === 2) {
|
||||||
|
done.resolve();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
await done.promise;
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should run through smoothly with ' + "'forEach'", async tools => {
|
||||||
|
let done = smartpromise.defer();
|
||||||
|
let counter = 0;
|
||||||
|
smartgulp.src(['./test/testfiles/*.md']).pipe(
|
||||||
|
gulpFunction.atEnd(async () => {
|
||||||
|
console.log('atEnd');
|
||||||
|
done.resolve();
|
||||||
|
})
|
||||||
|
);
|
||||||
|
await done.promise;
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.start();
|
1
test/testfiles/test01.md
Normal file
1
test/testfiles/test01.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# the 1st testfile
|
1
test/testfiles/test02.md
Normal file
1
test/testfiles/test02.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# the second testfile
|
1
test/testfiles/test03.md
Normal file
1
test/testfiles/test03.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# the third testfile
|
1
test/testfiles/test04.md
Normal file
1
test/testfiles/test04.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# the fourth testfile
|
1
test/testfiles/test05.md
Normal file
1
test/testfiles/test05.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# the fifth testfile
|
1
test/testfiles/test06.md
Normal file
1
test/testfiles/test06.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# the sixth testfile
|
1
test/testfiles/test07.md
Normal file
1
test/testfiles/test07.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# the seventh testfile
|
1
test/testfiles/test08.md
Normal file
1
test/testfiles/test08.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# the eighth testfile
|
1
test/testfiles/test09.md
Normal file
1
test/testfiles/test09.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# the nineth testfile
|
1
test/testfiles/test10.md
Normal file
1
test/testfiles/test10.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# the tenth testfile
|
1
test/testfiles/test11.md
Normal file
1
test/testfiles/test11.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# the eleventh testfile
|
1
test/testfiles/test12.md
Normal file
1
test/testfiles/test12.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# the twelveth testfile
|
1
test/testfiles/test13.md
Normal file
1
test/testfiles/test13.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# the second testfile
|
1
test/testfiles/test14.md
Normal file
1
test/testfiles/test14.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# the second testfile
|
1
test/testfiles/test15.md
Normal file
1
test/testfiles/test15.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# the second testfile
|
1
test/testfiles/test16.md
Normal file
1
test/testfiles/test16.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# the second testfile
|
1
test/testfiles/test17.md
Normal file
1
test/testfiles/test17.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# the second testfile
|
1
test/testfiles/test18.md
Normal file
1
test/testfiles/test18.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# the 18th testfile
|
@ -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.
|
|
108
ts/index.ts
108
ts/index.ts
@ -1,39 +1,87 @@
|
|||||||
/// <reference path="typings/tsd.d.ts" />
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
var through = require("through2");
|
import * as through2 from 'through2';
|
||||||
var path = require("path");
|
import { Transform } from 'stream';
|
||||||
var beautylog = require("beautylog");
|
|
||||||
|
|
||||||
//important vars
|
export type TExecutionMode = 'forEach' | 'forFirst' | 'atEnd';
|
||||||
var executionMode:string; //can be forEach or atEnd
|
|
||||||
var functionsToExecute;
|
export interface IPromiseFunction {
|
||||||
var runFunctionNames = function () {
|
(file?, enc?): PromiseLike<any>;
|
||||||
if (typeof functionsToExecute === "function" ) {
|
}
|
||||||
functionsToExecute();
|
|
||||||
} else if (Array.isArray(functionsToExecute)) {
|
let defaultExport = (
|
||||||
for (var anyFunction in functionsToExecute) {
|
functionsToExecuteArg: IPromiseFunction | IPromiseFunction[],
|
||||||
anyFunction();
|
executionModeArg: TExecutionMode = 'forEach'
|
||||||
|
): Transform => {
|
||||||
|
let promiseArray = [];
|
||||||
|
let runFunction = function(functionArg, file, enc) {
|
||||||
|
let returnValue = functionArg(file, enc);
|
||||||
|
if (typeof returnValue !== 'undefined' && typeof returnValue.then !== 'undefined') {
|
||||||
|
promiseArray.push(returnValue);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let checkAndRunFunction = function(file, enc) {
|
||||||
|
if (typeof functionsToExecuteArg === 'function') {
|
||||||
|
runFunction(functionsToExecuteArg, file, enc);
|
||||||
|
} else if (Array.isArray(functionsToExecuteArg)) {
|
||||||
|
for (let anyFunction in functionsToExecuteArg) {
|
||||||
|
runFunction(functionsToExecuteArg[anyFunction], file, enc);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
beautylog.error('gulp-callfunction: something is strange with the given arguments');
|
throw new Error('gulp-callfunction: something is strange with the given arguments');
|
||||||
|
}
|
||||||
|
return Promise.all(promiseArray);
|
||||||
|
};
|
||||||
|
|
||||||
|
let hasExecutedOnce = false;
|
||||||
|
let forEach = function(file, enc, cb) {
|
||||||
|
// the forEach function is called for every chunk
|
||||||
|
switch (executionModeArg) {
|
||||||
|
case 'forEach':
|
||||||
|
checkAndRunFunction(file, enc).then(function() {
|
||||||
|
cb(null, file);
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 'forFirst':
|
||||||
|
if (hasExecutedOnce) {
|
||||||
|
checkAndRunFunction(file, enc).then(function() {
|
||||||
|
cb(null, file);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
cb(null, file);
|
||||||
|
}
|
||||||
|
hasExecutedOnce = true;
|
||||||
|
break;
|
||||||
|
case 'atEnd':
|
||||||
|
cb();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let atEnd = function(cb) {
|
||||||
var forEach = function (file, enc, cb) {
|
if (executionModeArg === 'atEnd') {
|
||||||
if (executionMode === 'forEach') {
|
checkAndRunFunction(null, null).then(function() {
|
||||||
runFunctionNames();
|
cb();
|
||||||
}
|
});
|
||||||
//tell gulp that we are complete
|
} else {
|
||||||
return cb(null, file);
|
cb();
|
||||||
};
|
|
||||||
|
|
||||||
var atEnd = function() {
|
|
||||||
if (executionMode === "atEnd") {
|
|
||||||
runFunctionNames();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
module.exports = function (functionsToExecute:any|any[],executionMode:string = 'forEach') {
|
return through2.obj(forEach, atEnd);
|
||||||
this.functionsToExecute = functionsToExecute;
|
|
||||||
this.executionMode = executionMode;
|
|
||||||
return through.obj(forEach,atEnd);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export let forEach = (funcArg: IPromiseFunction) => {
|
||||||
|
return defaultExport(funcArg, 'forEach');
|
||||||
|
};
|
||||||
|
|
||||||
|
export let forFirst = (funcArg: IPromiseFunction) => {
|
||||||
|
return defaultExport(funcArg, 'forFirst');
|
||||||
|
};
|
||||||
|
|
||||||
|
export let atEnd = (funcArg: IPromiseFunction) => {
|
||||||
|
return defaultExport(funcArg, 'atEnd');
|
||||||
|
};
|
||||||
|
|
||||||
|
export default defaultExport;
|
||||||
|
15
ts/tsd.json
15
ts/tsd.json
@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "v4",
|
|
||||||
"repo": "borisyankov/DefinitelyTyped",
|
|
||||||
"ref": "master",
|
|
||||||
"path": "typings",
|
|
||||||
"bundle": "typings/tsd.d.ts",
|
|
||||||
"installed": {
|
|
||||||
"node/node.d.ts": {
|
|
||||||
"commit": "efa0c1196d7280640e624ac1e7fa604502e7bd63"
|
|
||||||
},
|
|
||||||
"colors/colors.d.ts": {
|
|
||||||
"commit": "3191f6e0088eee07c4d8fd24e4d27a40a60d9eb9"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
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" />
|
|
17
tslint.json
Normal file
17
tslint.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"extends": ["tslint:latest", "tslint-config-prettier"],
|
||||||
|
"rules": {
|
||||||
|
"semicolon": [true, "always"],
|
||||||
|
"no-console": false,
|
||||||
|
"ordered-imports": false,
|
||||||
|
"object-literal-sort-keys": false,
|
||||||
|
"member-ordering": {
|
||||||
|
"options":{
|
||||||
|
"order": [
|
||||||
|
"static-method"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"defaultSeverity": "warning"
|
||||||
|
}
|
Reference in New Issue
Block a user