Compare commits
26 Commits
Author | SHA1 | Date | |
---|---|---|---|
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 |
9
.gitignore
vendored
Normal file
9
.gitignore
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
node_modules/
|
||||||
|
.settings/
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
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
|
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: AcM6ooFjEIaWOC84QMxxugV3GtkMEoMI6zxy4oB9u9xihLopVZnm6c8FxIr+Wl2Ykjwj2deOuC7Q7QLtfH8/n4cVj1x7c32DJ21XJsE6uGm2opT7bSMm/NgcIvbkzWdPSyG8OpJEu8l///+YTceLdLV2Tn4lPobZRgu0KIF3Pg0Fo2V/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22IYA1J0wYd87th88TZHx7wgQyC+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=
|
||||||
|
26
README.md
Normal file
26
README.md
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# gulp-function
|
||||||
|
accepts call to execute in gulp pipeline.
|
||||||
|
|
||||||
|
### build status/Dependencies
|
||||||
|
[](https://travis-ci.org/pushrocks/gulp-function)
|
||||||
|
[](https://david-dm.org/pushrocks/gulp-function)
|
||||||
|
[](https://david-dm.org/pushrocks/gulp-function#info=devDependencies)
|
||||||
|
|
||||||
|
### 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'))
|
||||||
|
.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;
|
47
index.js
Normal file
47
index.js
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#!/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, logBoolArg) {
|
||||||
|
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 () {
|
||||||
|
if (typeof gulpFunction.functionsToExecute == "function") {
|
||||||
|
gulpFunction.functionsToExecute();
|
||||||
|
}
|
||||||
|
else if (Array.isArray(gulpFunction.functionsToExecute)) {
|
||||||
|
for (var anyFunction in gulpFunction.functionsToExecute) {
|
||||||
|
anyFunction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
beautylog.error('gulp-callfunction: something is strange with the given arguments');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var forEach = function (file, enc, cb) {
|
||||||
|
if (gulpFunction.logBool)
|
||||||
|
beautylog.log(gulpFunction.executionMode);
|
||||||
|
if (gulpFunction.executionMode === 'forEach') {
|
||||||
|
if (gulpFunction.logBool)
|
||||||
|
beautylog.log('is 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);
|
||||||
|
};
|
29
package.json
29
package.json
@ -1,24 +1,35 @@
|
|||||||
{
|
{
|
||||||
"name": "gulp-callfunction",
|
"name": "gulp-function",
|
||||||
"version": "0.0.2",
|
"version": "1.0.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": {
|
||||||
"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": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/pushrocks/gulp-callfunction.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",
|
||||||
"bugs": {
|
"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.0.4",
|
||||||
|
"through2": "2.0.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"gulp": "^3.9.0",
|
||||||
|
"npmts": "^2.0.2"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
2
test/README.md
Normal file
2
test/README.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#Test
|
||||||
|
This directory contains files for testing
|
17
test/test.js
Normal file
17
test/test.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
/// <reference path="typings/main.d.ts" />
|
||||||
|
var gulp = require("gulp");
|
||||||
|
var gulpFunction = require("../index.js");
|
||||||
|
var beautylog = require("beautylog");
|
||||||
|
var myFunction = function () {
|
||||||
|
beautylog.log("Mocha Test successfull!");
|
||||||
|
};
|
||||||
|
describe("gulpFunction", function () {
|
||||||
|
it("should run through smoothly", function () {
|
||||||
|
gulp.task('default', function () {
|
||||||
|
gulp.src('./test/test.md')
|
||||||
|
.pipe(gulpFunction(myFunction, 'forEach'))
|
||||||
|
.pipe(gulp.dest("./test/result/"));
|
||||||
|
});
|
||||||
|
gulp.start.apply(gulp, ['default']);
|
||||||
|
});
|
||||||
|
});
|
2
test/test.md
Normal file
2
test/test.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# Test.md
|
||||||
|
This is a 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.
|
|
47
ts/index.ts
47
ts/index.ts
@ -1,14 +1,45 @@
|
|||||||
/// <reference path="typings/tsd.d.ts" />
|
/// <reference path="typings/main.d.ts" />
|
||||||
var path, through;
|
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', logBoolArg = false) {
|
||||||
|
//important vars
|
||||||
|
var gulpFunction = {
|
||||||
|
executionMode: executionModeArg, //can be forEach or atEnd
|
||||||
|
functionsToExecute: functionsToExecuteArg,
|
||||||
|
logBool: logBoolArg
|
||||||
|
};
|
||||||
|
|
||||||
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) {
|
||||||
|
anyFunction();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
beautylog.error('gulp-callfunction: something is strange with the given arguments');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
var forEach = function (file, enc, cb) {
|
||||||
|
if (gulpFunction.logBool) beautylog.log(gulpFunction.executionMode);
|
||||||
|
if (gulpFunction.executionMode === 'forEach') {
|
||||||
|
if(gulpFunction.logBool) beautylog.log('is forEach');
|
||||||
|
runFunctionNames();
|
||||||
|
}
|
||||||
//tell gulp that we are complete
|
//tell gulp that we are complete
|
||||||
return cb(null, file);
|
return cb(null, file);
|
||||||
});
|
};
|
||||||
|
|
||||||
|
var atEnd = function(cb) {
|
||||||
|
if (gulpFunction.executionMode == "atEnd") {
|
||||||
|
runFunctionNames();
|
||||||
|
}
|
||||||
|
cb();
|
||||||
|
};
|
||||||
|
return through.obj(forEach,atEnd);
|
||||||
};
|
};
|
||||||
|
20
ts/test.ts
Normal file
20
ts/test.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
/// <reference path="typings/main.d.ts" />
|
||||||
|
var gulp = require("gulp");
|
||||||
|
var gulpFunction = require("../index.js");
|
||||||
|
var beautylog = require("beautylog");
|
||||||
|
|
||||||
|
var myFunction = function () {
|
||||||
|
beautylog.log("Mocha Test successfull!");
|
||||||
|
};
|
||||||
|
|
||||||
|
describe("gulpFunction",function(){
|
||||||
|
it("should run through smoothly",function(){
|
||||||
|
gulp.task('default',function() {
|
||||||
|
gulp.src('./test/test.md')
|
||||||
|
.pipe(gulpFunction(myFunction,'forEach'))
|
||||||
|
.pipe(gulp.dest("./test/result/"))
|
||||||
|
});
|
||||||
|
gulp.start.apply(gulp, ['default']);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -7,6 +7,9 @@
|
|||||||
"installed": {
|
"installed": {
|
||||||
"node/node.d.ts": {
|
"node/node.d.ts": {
|
||||||
"commit": "efa0c1196d7280640e624ac1e7fa604502e7bd63"
|
"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