Compare commits

...

7 Commits

Author SHA1 Message Date
4b02d17d6d 1.0.3 2016-02-12 05:36:31 +01:00
57350d6fee add better tests and coverage 2016-02-12 05:36:23 +01:00
dcdf0059cc 1.0.2 2016-02-02 15:21:45 +01:00
9cc9e15b04 update deps 2016-02-02 15:21:27 +01:00
6a19698617 1.0.1 2016-02-01 03:45:38 +01:00
bc53520869 update travis 2016-02-01 03:45:13 +01:00
752dec8fea update npmts 2016-02-01 03:43:29 +01:00
11 changed files with 75 additions and 51 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
node_modules/
.settings/
.idea/
coverage/
ts/*.js
ts/*.js.map

View File

@ -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: ZgxvXgxlJlDDx4sv2H+M0Z36sZHDKEYRntudQWKLaDt1T2VojfsigNORrDZcHCs6FZo8t2Klsqte8PqDvAn7BxXIo5K86aaZOyulcHnmDQS6rBhJYHm01qJj2B+t03EozcsueYGcQIVyFLBnKl5Yj8GdQ6iVGbimHvgym/Bbo6pKQlKHvv7a+tOSmtRffeG4jZU454MYqc38ZPtKftdknk7m4T0wUP2l9Y1jKva8Zjd4+cw+xOhFAStkySrq8uNBEINN8e5vqvaOxq1d7V8evK7JQLjDtLOaj67cHJ3u7ZjHA2zk1j/Rs7X2jkeqqRbG1zhSHUjjqvnZRzC6ygswOHBBnSzF9P+tN7+jcNcn09PLsKh/HyXq/aRFKsNtvKjUey4cM27yt/LRLis70hrRTgR9EDZ/Q4Aoa/P/ObYf0XDE1rH08nngeASdmGFN+6n6idSq8C7IQ/YfmmQBhIhTSaNSGsYcG827fB5EZLoojCDOuNIrfyMOJHrSy14rgNWiGRj7C0md4yP7qGP53JPU9pPZLzRiD2/y9KuZ4qnE/edj9+POmVCr+uz2ILFQcTkEb9gItfMQGLd5m5MtPHgVFcoslU14O8o5WyFdG80xDHBvyy+1TsqnyRPwwlLwzepqZeUltZKXiOMDRIRurDRC1jtwcf8kJmWboio3GLIdQFU=
secure: TWN/oiICeNbAhGTbwf75FnKhXnIvyA66FhNF7C0jpjn2SChSgTANai87r0f9oU9ZP3307XdGHB+fTTCJnk3upNiBoWZnkV8skkAlseOY4mVzF9mS0ZEkxVR32FjJDWfqzv6hC+Y9qNDsGs2+Avsm6fQUOispLXYAk6VzSQC1HgIfyOJtIWT5LqEyXyT6oJIZ7xwt1CYcIeEpHUiAaPYsMEpwF5OBDFByVmNV38VdRGIBsoQd3lixso7/zOOgYvjR4b/onz5WzeWYlhzAuyzOnRGr1r/9eXAzzkYydvgFx3ix5OlrreKVFB6OtMpz4jmHdu9YDGT5bcvL2bSU2SGVQM5Bx8zZXkAxACQR8ZvWmPaWYAWCu9wrW5oovjqFUV0iR26z/sTABJqz4GaXf/vFcll2EdTfUT6xj2kCodfxljaudjPUF27FSt1UJBC7jQky08wHb6+onrE8WoQXteIE2oxtHWEGOlV/GAz0+q4ih0bdOSKfThmux0iEFmeF16sWH9UdL2jBBKuus+fBPdhA3V6uwYQtsCAurhquQLISkf7kT3KujdLS302bEbkut+D1Kd22IYA1J0wYd87th88TZHx7wgQyC+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=

View File

@ -1,10 +1,12 @@
# gulp-function
accepts call to execute in gulp pipeline.
### build status/Dependencies
### Status
[![Build Status](https://travis-ci.org/pushrocks/gulp-function.svg?branch=v0.0.2)](https://travis-ci.org/pushrocks/gulp-function)
[![Dependency Status](https://david-dm.org/pushrocks/gulp-function.svg)](https://david-dm.org/pushrocks/gulp-function)
[![devDependency Status](https://david-dm.org/pushrocks/gulp-function/dev-status.svg)](https://david-dm.org/pushrocks/gulp-function#info=devDependencies)
[![bitHound Code](https://www.bithound.io/github/pushrocks/gulp-function/badges/code.svg)](https://www.bithound.io/github/pushrocks/gulp-function)
[![Coverage Status](https://coveralls.io/repos/github/pushrocks/gulp-function/badge.svg?branch=master)](https://coveralls.io/github/pushrocks/gulp-function?branch=master)
### Usage
```javascript
@ -17,7 +19,7 @@ var myFunction = function () {
gulp.task('gulpTest',function() {
gulp.src('./mydir/*.something')
.pipe(gulpFunction(myFunction,'forEach'))
.pipe(gulpFunction(myFunction,'forEach')) //read the notes below
.pipe(gulp.dest("./build/"))
});
```

View File

@ -4,22 +4,20 @@
var through = require("through2");
var path = require("path");
var beautylog = require("beautylog");
module.exports = function (functionsToExecuteArg, executionModeArg, logBoolArg) {
module.exports = function (functionsToExecuteArg, executionModeArg) {
if (executionModeArg === void 0) { executionModeArg = 'forEach'; }
if (logBoolArg === void 0) { logBoolArg = false; }
//important vars
var gulpFunction = {
executionMode: executionModeArg,
functionsToExecute: functionsToExecuteArg,
logBool: logBoolArg
functionsToExecute: functionsToExecuteArg
};
var runFunctionNames = function () {
if (typeof gulpFunction.functionsToExecute == "function") {
if (typeof gulpFunction.functionsToExecute === "function") {
gulpFunction.functionsToExecute();
}
else if (Array.isArray(gulpFunction.functionsToExecute)) {
for (var anyFunction in gulpFunction.functionsToExecute) {
anyFunction();
gulpFunction.functionsToExecute[anyFunction]();
}
}
else {
@ -27,18 +25,14 @@ module.exports = function (functionsToExecuteArg, executionModeArg, logBoolArg)
}
};
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") {
if (gulpFunction.executionMode === "atEnd") {
runFunctionNames();
}
cb();

View File

@ -1,6 +1,6 @@
{
"name": "gulp-function",
"version": "1.0.0",
"version": "1.0.3",
"description": "accepts a function call as parameter to execute in gulp pipeline",
"main": "index.js",
"scripts": {
@ -25,10 +25,11 @@
},
"homepage": "https://github.com/pushrocks/gulp-function",
"dependencies": {
"beautylog": "2.0.4",
"through2": "2.0.0"
"beautylog": "2.1.1",
"through2": "2.0.1"
},
"devDependencies": {
"gulp": "^3.9.0"
"gulp": "^3.9.1",
"npmts": "^2.2.3"
}
}

6
test/test.d.ts vendored Normal file
View 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;

View File

@ -1,17 +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("Mocha Test successfull!");
beautylog.log("Function executed");
};
var myFunction2 = function () {
beautylog.log("Function2 executed");
};
describe("gulpFunction", function () {
it("should run through smoothly", function () {
gulp.task('default', function () {
gulp.src('./test/test.md')
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/"));
});
gulp.start.apply(gulp, ['default']);
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/test02.md Normal file
View File

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

View File

@ -4,20 +4,19 @@ var path = require("path");
var beautylog = require("beautylog");
module.exports = function (functionsToExecuteArg:any|any[],executionModeArg:string = 'forEach', logBoolArg = false) {
module.exports = function (functionsToExecuteArg:any|any[],executionModeArg:string = 'forEach') {
//important vars
var gulpFunction = {
executionMode: executionModeArg, //can be forEach or atEnd
functionsToExecute: functionsToExecuteArg,
logBool: logBoolArg
functionsToExecute: functionsToExecuteArg
};
var runFunctionNames = function () {
if (typeof gulpFunction.functionsToExecute == "function" ) {
if (typeof gulpFunction.functionsToExecute === "function" ) {
gulpFunction.functionsToExecute();
} else if (Array.isArray(gulpFunction.functionsToExecute)) {
for (var anyFunction in gulpFunction.functionsToExecute) {
anyFunction();
gulpFunction.functionsToExecute[anyFunction]();
}
} else {
beautylog.error('gulp-callfunction: something is strange with the given arguments');
@ -26,9 +25,7 @@ module.exports = function (functionsToExecuteArg:any|any[],executionModeArg:stri
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
@ -36,7 +33,7 @@ module.exports = function (functionsToExecuteArg:any|any[],executionModeArg:stri
};
var atEnd = function(cb) {
if (gulpFunction.executionMode == "atEnd") {
if (gulpFunction.executionMode === "atEnd") {
runFunctionNames();
}
cb();

View File

@ -4,17 +4,30 @@ var gulpFunction = require("../index.js");
var beautylog = require("beautylog");
var myFunction = function () {
beautylog.log("Mocha Test successfull!");
beautylog.log("Function executed");
};
var myFunction2 = function () {
beautylog.log("Function2 executed");
};
describe("gulpFunction",function(){
it("should run through smoothly",function(){
gulp.task('default',function() {
gulp.src('./test/test.md')
it("should run through smoothly with " + "'forEach'".blue,function(){
gulp.src('./test/*.md')
.pipe(gulpFunction(myFunction,'forEach'))
.pipe(gulp.dest("./test/result/"))
.pipe(gulp.dest("./test/result/"));
gulp.src('./test/*.md')
.pipe(gulpFunction([myFunction,myFunction2],'forEach'))
.pipe(gulp.dest("./test/result/"));
});
gulp.start.apply(gulp, ['default']);
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/"));
});
});