Compare commits

...

10 Commits

Author SHA1 Message Date
22e3dc6136 0.0.8 2015-11-24 13:44:38 +01:00
e69e8df875 fix:added callback to function() atEnd 2015-11-24 13:44:32 +01:00
4cb24a4a6d add dev dependency badge 2015-10-26 16:25:08 +01:00
ebac042791 0.0.7 2015-10-26 16:22:29 +01:00
d8fc992ba3 0.0.6 2015-10-26 16:21:33 +01:00
82def89388 0.0.5 2015-10-26 16:20:49 +01:00
4b832bbf95 added automatic version release through travis for npm 2015-10-26 16:20:41 +01:00
cf8182b86a 0.0.4 2015-10-26 16:18:52 +01:00
c708f964ec added test 2015-10-26 16:18:37 +01:00
f9c4fb9887 small fix 2015-10-25 22:46:22 +01:00
12 changed files with 99 additions and 78 deletions

View File

@ -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

View File

@ -4,6 +4,7 @@ accepts call to execute in gulp pipeline.
### build status/Dependencies
[![Build Status](https://travis-ci.org/pushrocks/gulp-callfunction.svg?branch=v0.0.2)](https://travis-ci.org/pushrocks/gulp-callfunction)
[![Dependency Status](https://david-dm.org/pushrocks/gulp-callfunction.svg)](https://david-dm.org/pushrocks/gulp-callfunction)
[![devDependency Status](https://david-dm.org/pushrocks/gulp-callfunction/dev-status.svg)](https://david-dm.org/pushrocks/gulp-callfunction#info=devDependencies)
### Usage
```javascript
@ -17,7 +18,7 @@ var myFunction = function () {
gulp.task('gulpTest',function() {
gulp.src('./mydir/*.something')
.pipe(gulpCallFunction(myFunction,'forEach'))
.pipe(gulp.dest(./build/))
.pipe(gulp.dest("./build/"))
});
```

View File

@ -3,14 +3,17 @@ var through = require("through2");
var path = require("path");
var beautylog = require("beautylog");
//important vars
var executionMode; //can be forEach or atEnd
var functionsToExecute;
var gulpCallFunction = {
executionMode: 'forEach',
functionsToExecute: undefined,
logBool: false
};
var runFunctionNames = function () {
if (typeof functionsToExecute === "function") {
functionsToExecute();
if (typeof gulpCallFunction.functionsToExecute == "function") {
gulpCallFunction.functionsToExecute();
}
else if (Array.isArray(functionsToExecute)) {
for (var anyFunction in functionsToExecute) {
else if (Array.isArray(gulpCallFunction.functionsToExecute)) {
for (var anyFunction in gulpCallFunction.functionsToExecute) {
anyFunction();
}
}
@ -19,20 +22,27 @@ var runFunctionNames = function () {
}
};
var forEach = function (file, enc, cb) {
if (executionMode === 'forEach') {
if (gulpCallFunction.logBool)
beautylog.log(gulpCallFunction.executionMode);
if (gulpCallFunction.executionMode === 'forEach') {
if (gulpCallFunction.logBool)
beautylog.log('is forEach');
runFunctionNames();
}
//tell gulp that we are complete
return cb(null, file);
};
var atEnd = function () {
if (executionMode === "atEnd") {
var atEnd = function (cb) {
if (gulpCallFunction.executionMode == "atEnd") {
runFunctionNames();
}
cb();
};
module.exports = function (functionsToExecute, executionMode) {
module.exports = function (functionsToExecute, executionMode, logBool) {
if (executionMode === void 0) { executionMode = 'forEach'; }
this.functionsToExecute = functionsToExecute;
this.executionMode = executionMode;
if (logBool === void 0) { logBool = false; }
gulpCallFunction.functionsToExecute = functionsToExecute;
gulpCallFunction.executionMode = executionMode;
gulpCallFunction.logBool = logBool;
return through.obj(forEach, atEnd);
};

View File

@ -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 ]

View File

@ -1,10 +1,10 @@
{
"name": "gulp-callfunction",
"version": "0.0.3",
"version": "0.0.8",
"description": "accepts a function call as parameter to execute in gulp pipeline",
"main": "index.js",
"scripts": {
"test": "(cd ts/compile && gulp)",
"test": "(cd ts/compile && node compile.js) && (node test.js)",
"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)"
@ -29,6 +29,7 @@
"gulp-typescript": "^2.9.2"
},
"dependencies": {
"beautylog": "0.0.15"
"beautylog": "0.0.15",
"through2": "^2.0.0"
}
}

12
test.js Normal file
View File

@ -0,0 +1,12 @@
/// <reference path="typings/tsd.d.ts" />
var gulp = require("gulp");
var gulpCallFunction = require("./index.js");
var myFunction = function () {
console.log("Hello World!");
};
gulp.task('default', function () {
gulp.src('./test/test.md')
.pipe(gulpCallFunction(myFunction, 'forEach'))
.pipe(gulp.dest("./test/result/"));
});
gulp.start.apply(gulp, ['default']);

2
test/README.md Normal file
View File

@ -0,0 +1,2 @@
#Test
This directory contains files for testing

2
test/result/test.md Normal file
View File

@ -0,0 +1,2 @@
# Test.md
This is a test file for the test.js gulp pipeline

2
test/test.md Normal file
View File

@ -0,0 +1,2 @@
# Test.md
This is a test file for the test.js gulp pipeline

View File

@ -11,6 +11,16 @@ gulp.task('compileTS', function() {
return stream;
});
gulp.task('default',['compileTS'], function() {
gulp.task('compileTestTS', function() {
var stream = gulp.src('../test.ts')
.pipe(gulpTypescript({
out: "test.js"
}))
.pipe(gulp.dest("../../"));
return stream;
});
gulp.task('default',['compileTS','compileTestTS'], function() {
console.log('Typescript compiled');
});
});
gulp.start.apply(gulp, ['default']);

View File

@ -4,13 +4,17 @@ var path = require("path");
var beautylog = require("beautylog");
//important vars
var executionMode:string; //can be forEach or atEnd
var functionsToExecute;
var gulpCallFunction = {
executionMode: 'forEach', //can be forEach or atEnd
functionsToExecute: undefined,
logBool: false
};
var runFunctionNames = function () {
if (typeof functionsToExecute === "function" ) {
functionsToExecute();
} else if (Array.isArray(functionsToExecute)) {
for (var anyFunction in functionsToExecute) {
if (typeof gulpCallFunction.functionsToExecute == "function" ) {
gulpCallFunction.functionsToExecute();
} else if (Array.isArray(gulpCallFunction.functionsToExecute)) {
for (var anyFunction in gulpCallFunction.functionsToExecute) {
anyFunction();
}
} else {
@ -20,20 +24,24 @@ var runFunctionNames = function () {
var forEach = function (file, enc, cb) {
if (executionMode === 'forEach') {
runFunctionNames();
}
//tell gulp that we are complete
return cb(null, file);
if (gulpCallFunction.logBool) beautylog.log(gulpCallFunction.executionMode);
if (gulpCallFunction.executionMode === 'forEach') {
if(gulpCallFunction.logBool) beautylog.log('is forEach');
runFunctionNames();
}
//tell gulp that we are complete
return cb(null, file);
};
var atEnd = function() {
if (executionMode === "atEnd") {
runFunctionNames();
}
var atEnd = function(cb) {
if (gulpCallFunction.executionMode == "atEnd") {
runFunctionNames();
}
cb();
};
module.exports = function (functionsToExecute:any|any[],executionMode:string = 'forEach') {
this.functionsToExecute = functionsToExecute;
this.executionMode = executionMode;
module.exports = function (functionsToExecute:any|any[],executionMode:string = 'forEach', logBool = false) {
gulpCallFunction.functionsToExecute = functionsToExecute;
gulpCallFunction.executionMode = executionMode;
gulpCallFunction.logBool = logBool;
return through.obj(forEach,atEnd);
};

14
ts/test.ts Normal file
View File

@ -0,0 +1,14 @@
/// <reference path="typings/tsd.d.ts" />
var gulp = require("gulp");
var gulpCallFunction = require("./index.js");
var myFunction = function () {
console.log("Hello World!");
}
gulp.task('default',function() {
gulp.src('./test/test.md')
.pipe(gulpCallFunction(myFunction,'forEach'))
.pipe(gulp.dest("./test/result/"))
});
gulp.start.apply(gulp, ['default']);