Compare commits
32 Commits
Author | SHA1 | Date | |
---|---|---|---|
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 | |||
c6c352f587 | |||
3930912f25 | |||
b6a6c62962 | |||
e43c627307 |
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
node_modules/
|
||||
.settings/
|
||||
.idea/
|
||||
coverage/
|
||||
|
||||
ts/*.js
|
||||
ts/*.js.map
|
||||
ts/typings/
|
||||
test/result/
|
||||
|
3
.npmignore
Normal file
3
.npmignore
Normal file
@ -0,0 +1,3 @@
|
||||
ts/
|
||||
test/
|
||||
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/0kS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22IYA1J0wYd87th88TZHx7wgQyC+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=
|
||||
|
28
README.md
Normal file
28
README.md
Normal file
@ -0,0 +1,28 @@
|
||||
# gulp-function
|
||||
accepts call to execute in gulp pipeline.
|
||||
|
||||
### Status
|
||||
[](https://travis-ci.org/pushrocks/gulp-function)
|
||||
[](https://david-dm.org/pushrocks/gulp-function)
|
||||
[](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
|
||||
```javascript
|
||||
var gulp = require("gulp");
|
||||
var gulpFunction = require("gulp-function");
|
||||
|
||||
var myFunction = function () {
|
||||
console.log("Hello World!")
|
||||
}
|
||||
|
||||
gulp.task('gulpTest',function() {
|
||||
gulp.src('./mydir/*.something')
|
||||
.pipe(gulpFunction(myFunction,'forEach')) //read the notes below
|
||||
.pipe(gulp.dest("./build/"))
|
||||
});
|
||||
```
|
||||
|
||||
>Note: The first argument of gulpFunction can also be an array of multiple functionnames.
|
||||
>Note: the second argument can be empty (defaults to 'forEach') or 'atEnd'
|
4
index.d.ts
vendored
Normal file
4
index.d.ts
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
/// <reference path="ts/typings/main.d.ts" />
|
||||
declare var through: any;
|
||||
declare var path: any;
|
||||
declare var beautylog: any;
|
41
index.js
Normal file
41
index.js
Normal file
@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/// <reference path="typings/main.d.ts" />
|
||||
var through = require("through2");
|
||||
var path = require("path");
|
||||
var beautylog = require("beautylog");
|
||||
module.exports = function (functionsToExecuteArg, executionModeArg) {
|
||||
if (executionModeArg === void 0) { executionModeArg = 'forEach'; }
|
||||
//important vars
|
||||
var gulpFunction = {
|
||||
executionMode: executionModeArg,
|
||||
functionsToExecute: functionsToExecuteArg
|
||||
};
|
||||
var runFunctionNames = function () {
|
||||
if (typeof gulpFunction.functionsToExecute === "function") {
|
||||
gulpFunction.functionsToExecute();
|
||||
}
|
||||
else if (Array.isArray(gulpFunction.functionsToExecute)) {
|
||||
for (var anyFunction in gulpFunction.functionsToExecute) {
|
||||
gulpFunction.functionsToExecute[anyFunction]();
|
||||
}
|
||||
}
|
||||
else {
|
||||
beautylog.error('gulp-callfunction: something is strange with the given arguments');
|
||||
}
|
||||
};
|
||||
var forEach = function (file, enc, cb) {
|
||||
if (gulpFunction.executionMode === 'forEach') {
|
||||
runFunctionNames();
|
||||
}
|
||||
//tell gulp that we are complete
|
||||
return cb(null, file);
|
||||
};
|
||||
var atEnd = function (cb) {
|
||||
if (gulpFunction.executionMode === "atEnd") {
|
||||
runFunctionNames();
|
||||
}
|
||||
cb();
|
||||
};
|
||||
return through.obj(forEach, atEnd);
|
||||
};
|
4
npmts.json
Normal file
4
npmts.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"mode":"default",
|
||||
"coveralls":true
|
||||
}
|
29
package.json
29
package.json
@ -1,24 +1,35 @@
|
||||
{
|
||||
"name": "gulp-callfunction",
|
||||
"version": "0.0.2",
|
||||
"name": "gulp-function",
|
||||
"version": "1.0.4",
|
||||
"description": "accepts a function call as parameter to execute in gulp pipeline",
|
||||
"main": "index.js",
|
||||
"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://github.com/pushrocks/gulp-function.git"
|
||||
},
|
||||
"keywords": [
|
||||
"json",
|
||||
"jade",
|
||||
"template"
|
||||
"gulpplugin",
|
||||
"gulp",
|
||||
"function"
|
||||
],
|
||||
"author": "Smart Coordination GmbH <office@push.rocks> (https://push.rocks)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/pushrocks/gulp-callfunction/issues"
|
||||
"url": "https://github.com/pushrocks/gulp-function/issues"
|
||||
},
|
||||
"homepage": "https://github.com/pushrocks/gulp-callfunction"
|
||||
"homepage": "https://github.com/pushrocks/gulp-function",
|
||||
"dependencies": {
|
||||
"beautylog": "2.1.1",
|
||||
"through2": "2.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gulp": "^3.9.1",
|
||||
"npmts": "^2.2.3"
|
||||
}
|
||||
}
|
||||
|
2
test/README.md
Normal file
2
test/README.md
Normal file
@ -0,0 +1,2 @@
|
||||
#Test
|
||||
This directory contains files for testing
|
6
test/test.d.ts
vendored
Normal file
6
test/test.d.ts
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
/// <reference path="ts/typings/main.d.ts" />
|
||||
declare var gulp: any;
|
||||
declare var gulpFunction: any;
|
||||
declare var beautylog: any;
|
||||
declare var myFunction: () => void;
|
||||
declare var myFunction2: () => void;
|
30
test/test.js
Normal file
30
test/test.js
Normal file
@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/// <reference path="typings/main.d.ts" />
|
||||
var gulp = require("gulp");
|
||||
var gulpFunction = require("../index.js");
|
||||
var beautylog = require("beautylog");
|
||||
var myFunction = function () {
|
||||
beautylog.log("Function executed");
|
||||
};
|
||||
var myFunction2 = function () {
|
||||
beautylog.log("Function2 executed");
|
||||
};
|
||||
describe("gulpFunction", function () {
|
||||
it("should run through smoothly with " + "'forEach'".blue, function () {
|
||||
gulp.src('./test/*.md')
|
||||
.pipe(gulpFunction(myFunction, 'forEach'))
|
||||
.pipe(gulp.dest("./test/result/"));
|
||||
gulp.src('./test/*.md')
|
||||
.pipe(gulpFunction([myFunction, myFunction2], 'forEach'))
|
||||
.pipe(gulp.dest("./test/result/"));
|
||||
});
|
||||
it("should run through smoothly with " + "'atEnd'".blue, function () {
|
||||
gulp.src('./test/*.md')
|
||||
.pipe(gulpFunction(myFunction, 'atEnd'))
|
||||
.pipe(gulp.dest("./test/result/"));
|
||||
gulp.src('./test/*.md')
|
||||
.pipe(gulpFunction([myFunction, myFunction2], 'atEnd'))
|
||||
.pipe(gulp.dest("./test/result/"));
|
||||
});
|
||||
});
|
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.
|
44
ts/index.ts
44
ts/index.ts
@ -1,14 +1,42 @@
|
||||
/// <reference path="typings/tsd.d.ts" />
|
||||
var path, through;
|
||||
/// <reference path="typings/main.d.ts" />
|
||||
var through = require("through2");
|
||||
var path = require("path");
|
||||
var beautylog = require("beautylog");
|
||||
|
||||
through = require("through2");
|
||||
path = require("path");
|
||||
|
||||
module.exports = (jsonObject,type = undefined) => {
|
||||
|
||||
module.exports = function (functionsToExecuteArg:any|any[],executionModeArg:string = 'forEach') {
|
||||
//important vars
|
||||
var gulpFunction = {
|
||||
executionMode: executionModeArg, //can be forEach or atEnd
|
||||
functionsToExecute: functionsToExecuteArg
|
||||
};
|
||||
|
||||
return through.obj((file, enc, cb) => {
|
||||
var runFunctionNames = function () {
|
||||
if (typeof gulpFunction.functionsToExecute === "function" ) {
|
||||
gulpFunction.functionsToExecute();
|
||||
} else if (Array.isArray(gulpFunction.functionsToExecute)) {
|
||||
for (var anyFunction in gulpFunction.functionsToExecute) {
|
||||
gulpFunction.functionsToExecute[anyFunction]();
|
||||
}
|
||||
} else {
|
||||
beautylog.error('gulp-callfunction: something is strange with the given arguments');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var forEach = function (file, enc, cb) {
|
||||
if (gulpFunction.executionMode === 'forEach') {
|
||||
runFunctionNames();
|
||||
}
|
||||
//tell gulp that we are complete
|
||||
return cb(null, file);
|
||||
});
|
||||
};
|
||||
|
||||
var atEnd = function(cb) {
|
||||
if (gulpFunction.executionMode === "atEnd") {
|
||||
runFunctionNames();
|
||||
}
|
||||
cb();
|
||||
};
|
||||
return through.obj(forEach,atEnd);
|
||||
};
|
||||
|
33
ts/test.ts
Normal file
33
ts/test.ts
Normal file
@ -0,0 +1,33 @@
|
||||
/// <reference path="typings/main.d.ts" />
|
||||
var gulp = require("gulp");
|
||||
var gulpFunction = require("../index.js");
|
||||
var beautylog = require("beautylog");
|
||||
|
||||
var myFunction = function () {
|
||||
beautylog.log("Function executed");
|
||||
};
|
||||
var myFunction2 = function () {
|
||||
beautylog.log("Function2 executed");
|
||||
};
|
||||
|
||||
describe("gulpFunction",function(){
|
||||
it("should run through smoothly with " + "'forEach'".blue,function(){
|
||||
gulp.src('./test/*.md')
|
||||
.pipe(gulpFunction(myFunction,'forEach'))
|
||||
.pipe(gulp.dest("./test/result/"));
|
||||
gulp.src('./test/*.md')
|
||||
.pipe(gulpFunction([myFunction,myFunction2],'forEach'))
|
||||
.pipe(gulp.dest("./test/result/"));
|
||||
|
||||
});
|
||||
|
||||
it("should run through smoothly with " + "'atEnd'".blue,function(){
|
||||
gulp.src('./test/*.md')
|
||||
.pipe(gulpFunction(myFunction,'atEnd'))
|
||||
.pipe(gulp.dest("./test/result/"));
|
||||
gulp.src('./test/*.md')
|
||||
.pipe(gulpFunction([myFunction,myFunction2],'atEnd'))
|
||||
.pipe(gulp.dest("./test/result/"));
|
||||
});
|
||||
});
|
||||
|
@ -7,6 +7,9 @@
|
||||
"installed": {
|
||||
"node/node.d.ts": {
|
||||
"commit": "efa0c1196d7280640e624ac1e7fa604502e7bd63"
|
||||
},
|
||||
"colors/colors.d.ts": {
|
||||
"commit": "3191f6e0088eee07c4d8fd24e4d27a40a60d9eb9"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
7
ts/typings.json
Normal file
7
ts/typings.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"ambientDependencies": {
|
||||
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts",
|
||||
"mocha": "github:Bartvds/tsd-deftools/typings/DefinitelyTyped/mocha/mocha.d.ts",
|
||||
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts"
|
||||
}
|
||||
}
|
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
1
ts/typings/tsd.d.ts
vendored
1
ts/typings/tsd.d.ts
vendored
@ -1 +0,0 @@
|
||||
/// <reference path="node/node.d.ts" />
|
Reference in New Issue
Block a user