Compare commits
21 Commits
Author | SHA1 | Date | |
---|---|---|---|
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/
|
@ -10,7 +10,7 @@ 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=
|
||||
secure: ZgxvXgxlJlDDx4sv2H+M0Z36sZHDKEYRntudQWKLaDt1T2VojfsigNORrDZcHCs6FZo8t2Klsqte8PqDvAn7BxXIo5K86aaZOyulcHnmDQS6rBhJYHm01qJj2B+t03EozcsueYGcQIVyFLBnKl5Yj8GdQ6iVGbimHvgym/Bbo6pKQlKHvv7a+tOSmtRffeG4jZU454MYqc38ZPtKftdknk7m4T0wUP2l9Y1jKva8Zjd4+cw+xOhFAStkySrq8uNBEINN8e5vqvaOxq1d7V8evK7JQLjDtLOaj67cHJ3u7ZjHA2zk1j/Rs7X2jkeqqRbG1zhSHUjjqvnZRzC6ygswOHBBnSzF9P+tN7+jcNcn09PLsKh/HyXq/aRFKsNtvKjUey4cM27yt/LRLis70hrRTgR9EDZ/Q4Aoa/P/ObYf0XDE1rH08nngeASdmGFN+6n6idSq8C7IQ/YfmmQBhIhTSaNSGsYcG827fB5EZLoojCDOuNIrfyMOJHrSy14rgNWiGRj7C0md4yP7qGP53JPU9pPZLzRiD2/y9KuZ4qnE/edj9+POmVCr+uz2ILFQcTkEb9gItfMQGLd5m5MtPHgVFcoslU14O8o5WyFdG80xDHBvyy+1TsqnyRPwwlLwzepqZeUltZKXiOMDRIRurDRC1jtwcf8kJmWboio3GLIdQFU=
|
||||
on:
|
||||
tags: true
|
||||
repo: pushrocks/gulp-callfunction
|
||||
|
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);
|
||||
};
|
22
package.json
22
package.json
@ -1,14 +1,17 @@
|
||||
{
|
||||
"name": "gulp-callfunction",
|
||||
"version": "0.0.2",
|
||||
"name": "gulp-function",
|
||||
"version": "0.0.12",
|
||||
"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",
|
||||
@ -18,7 +21,14 @@
|
||||
"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.0.4",
|
||||
"through2": "2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gulp": "^3.9.0"
|
||||
}
|
||||
}
|
||||
|
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.
|
49
ts/index.ts
49
ts/index.ts
@ -1,14 +1,45 @@
|
||||
/// <reference path="typings/tsd.d.ts" />
|
||||
var path, through;
|
||||
|
||||
through = require("through2");
|
||||
path = require("path");
|
||||
|
||||
module.exports = (jsonObject,type = undefined) => {
|
||||
/// <reference path="typings/main.d.ts" />
|
||||
var through = require("through2");
|
||||
var path = require("path");
|
||||
var beautylog = require("beautylog");
|
||||
|
||||
|
||||
return through.obj((file, enc, cb) => {
|
||||
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
|
||||
};
|
||||
|
||||
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);
|
||||
};
|
||||
|
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": {
|
||||
"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