Compare commits

...

8 Commits

Author SHA1 Message Date
a34a1b89fe 2.2.10 2017-09-07 22:33:43 +02:00
f4455a9b91 update dependencies 2017-09-07 22:33:40 +02:00
1a01198d7f 2.2.9 2017-04-30 17:28:18 +02:00
b3ec364a1d 2.2.8 2017-04-30 17:23:26 +02:00
5d15c96511 update docs and .gitignore 2017-04-30 17:23:22 +02:00
f6e071156b 2.2.7 2017-04-30 17:11:50 +02:00
63fe7c7423 update README 2017-04-30 17:11:40 +02:00
c8dcdc0df4 update README 2017-04-30 17:11:19 +02:00
6 changed files with 383 additions and 316 deletions

8
.gitignore vendored
View File

@ -1,13 +1,5 @@
node_modules/ node_modules/
.settings/
.idea/
coverage/ coverage/
docs/
public/ public/
pages/ pages/
ts/*.js
ts/*.js.map
ts/typings/
test/result/

View File

@ -1,15 +1,16 @@
# gulp-function # gulp-function
accepts call to execute in gulp pipeline. accepts a function call as parameter to execute in gulp pipeline
## Availabililty ## Availabililty
[![npm](https://push.rocks/assets/repo-button-npm.svg)](https://www.npmjs.com/package/gulp-function) [![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/gulp-function)
[![git](https://push.rocks/assets/repo-button-git.svg)](https://gitlab.com/pushrocks/gulp-function) [![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/gulp-function)
[![git](https://push.rocks/assets/repo-button-mirror.svg)](https://github.com/pushrocks/gulp-function) [![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/gulp-function)
[![docs](https://push.rocks/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/gulp-function/) [![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/gulp-function/)
## Status for master ## Status for master
[![build status](https://gitlab.com/pushrocks/gulp-function/badges/master/build.svg)](https://gitlab.com/pushrocks/gulp-function/commits/master) [![build status](https://GitLab.com/pushrocks/gulp-function/badges/master/build.svg)](https://GitLab.com/pushrocks/gulp-function/commits/master)
[![coverage report](https://gitlab.com/pushrocks/gulp-function/badges/master/coverage.svg)](https://gitlab.com/pushrocks/gulp-function/commits/master) [![coverage report](https://GitLab.com/pushrocks/gulp-function/badges/master/coverage.svg)](https://GitLab.com/pushrocks/gulp-function/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/gulp-function.svg)](https://www.npmjs.com/package/gulp-function)
[![Dependency Status](https://david-dm.org/pushrocks/gulp-function.svg)](https://david-dm.org/pushrocks/gulp-function) [![Dependency Status](https://david-dm.org/pushrocks/gulp-function.svg)](https://david-dm.org/pushrocks/gulp-function)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/gulp-function/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/gulp-function/master/dependencies/npm) [![bitHound Dependencies](https://www.bithound.io/github/pushrocks/gulp-function/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/gulp-function/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/gulp-function/badges/code.svg)](https://www.bithound.io/github/pushrocks/gulp-function) [![bitHound Code](https://www.bithound.io/github/pushrocks/gulp-function/badges/code.svg)](https://www.bithound.io/github/pushrocks/gulp-function)
@ -17,45 +18,12 @@ accepts call to execute in gulp pipeline.
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/) [![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/) [![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
### Usage ## Usage
```javascript Use TypeScript for best in class instellisense.
import * as gulp from 'gulp';
import gulpFunction from 'gulp-function' // default ES6 export
// import {forFirst, forEach, atEnd} from 'gulp-function'
let Q = require("q");
let myFunction = function (file, enc) { // file and enc are optional in case you want to modify the file object For further information read the linked docs at the top of this README.
let done = Q.defer();
console.log("Hello World!")
// NOTE:
// you can use done.resolve as callback function
// of any async tasks within this function
done.resolve();
return done.promise;
}
gulp.task('gulpTest',function() { > MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
let stream = gulp.src('./mydir/*.something') | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
.pipe(gulpFunction(myFunction,'forEach')) //read the notes below
// .pipe(forEach(myFunction)) // if imported as >> import { forEach } from 'gulp-function' <<
.pipe(gulp.dest("./build/"));
return stream; // by returning the stream gulp knows when our task has finished.
});
```
### Notes: [![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks)
* The first argument of gulpFunction can also be an **array of multiple functionnames**.
Each function can return a promise. The pipe stop will finish when every promise is fullfilled.
When providing an array of functions be careful with modifying the file object -> race condition
* The second argument can be empty, it defaults to "forEach"
* The following options are available:
* "forFirst" - executes when first chunk/vinylfile of the stream reaches the pipestop.
file is pushed further down the line when function's returned promise is fullfilled.
* "forEach" - executes like "forFirst" but with every chunk/vinylfile in the stream;
* "atEnd" - executes after all chunks have passed and are processed in full.
That means the stream's "finish" event fires **before "atLast" is executed**!!!
[![npm](https://push.rocks/assets/repo-header.svg)](https://push.rocks)

40
docs/index.md Normal file
View File

@ -0,0 +1,40 @@
### Usage
```javascript
import * as gulp from 'gulp';
import gulpFunction from 'gulp-function' // default ES6 export
// import {forFirst, forEach, atEnd} from 'gulp-function'
let Q = require("q");
let myFunction = function (file, enc) { // file and enc are optional in case you want to modify the file object
let done = Q.defer();
console.log("Hello World!")
// NOTE:
// you can use done.resolve as callback function
// of any async tasks within this function
done.resolve();
return done.promise;
}
gulp.task('gulpTest',function() {
let stream = gulp.src('./mydir/*.something')
.pipe(gulpFunction(myFunction,'forEach')) //read the notes below
// .pipe(forEach(myFunction)) // if imported as >> import { forEach } from 'gulp-function' <<
.pipe(gulp.dest("./build/"));
return stream; // by returning the stream gulp knows when our task has finished.
});
```
### Notes:
* The first argument of gulpFunction can also be an **array of multiple functionnames**.
Each function can return a promise. The pipe stop will finish when every promise is fullfilled.
When providing an array of functions be careful with modifying the file object -> race condition
* The second argument can be empty, it defaults to "forEach"
* The following options are available:
* "forFirst" - executes when first chunk/vinylfile of the stream reaches the pipestop.
file is pushed further down the line when function's returned promise is fullfilled.
* "forEach" - executes like "forFirst" but with every chunk/vinylfile in the stream;
* "atEnd" - executes after all chunks have passed and are processed in full.
That means the stream's "finish" event fires **before "atLast" is executed**!!!

View File

@ -1,14 +1,11 @@
{ {
"name": "gulp-function", "name": "gulp-function",
"version": "2.2.6", "version": "2.2.10",
"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": "dist/index.js", "main": "dist/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",
"scripts": { "scripts": {
"test": "(npmts)", "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",
@ -27,12 +24,10 @@
"homepage": "https://gitlab.com/pushrocks/gulp-function", "homepage": "https://gitlab.com/pushrocks/gulp-function",
"dependencies": { "dependencies": {
"@types/through2": "^2.0.32", "@types/through2": "^2.0.32",
"smartq": "^1.1.1",
"through2": "^2.0.3", "through2": "^2.0.3",
"typings-global": "^1.0.16" "typings-global": "^1.0.16"
}, },
"devDependencies": { "devDependencies": {
"beautylog": "^6.1.10",
"gulp": "^3.9.1", "gulp": "^3.9.1",
"smartgulp": "^1.0.1", "smartgulp": "^1.0.1",
"tapbundle": "^1.0.10" "tapbundle": "^1.0.10"

View File

@ -2,12 +2,10 @@ import { expect, tap } from 'tapbundle'
import * as smartgulp from 'smartgulp' import * as smartgulp from 'smartgulp'
let gulp = require('gulp') let gulp = require('gulp')
import * as gulpFunction from '../dist/index' import * as gulpFunction from '../ts/index'
import * as beautylog from 'beautylog'
let smartq = require('smartq') let smartq = require('smartq')
tap.test('should run through smoothly with ' + "'forEach'", async (tools) => { tap.test('should run through smoothly with ' + "'forEach'", async (tools) => {
let done = smartq.defer() let done = smartq.defer()
let counter = 0 let counter = 0

578
yarn.lock

File diff suppressed because it is too large Load Diff