From 63cf7091a1f344964aefbbe44deb7211139c4466 Mon Sep 17 00:00:00 2001 From: PhilKunz Date: Wed, 19 Oct 2016 00:35:41 +0200 Subject: [PATCH] add possibility to modify the file object --- .gitignore | 2 + .gitlab-ci.yml | 30 ++++++--- README.md | 26 +++++--- dist/gulpfunction.plugins.d.ts | 3 - dist/gulpfunction.plugins.js | 6 -- dist/index.d.ts | 6 +- dist/index.js | 68 ++++++++++---------- npmextra.json | 5 ++ npmts.json | 4 -- package.json | 10 +-- test/test.js | 7 +-- ts/gulpfunction.plugins.ts | 4 -- ts/index.ts | 110 ++++++++++++++++++--------------- ts/tsd.json | 15 ----- tslint.json | 3 + 15 files changed, 159 insertions(+), 140 deletions(-) delete mode 100644 dist/gulpfunction.plugins.d.ts delete mode 100644 dist/gulpfunction.plugins.js create mode 100644 npmextra.json delete mode 100644 npmts.json delete mode 100644 ts/gulpfunction.plugins.ts delete mode 100644 ts/tsd.json create mode 100644 tslint.json diff --git a/.gitignore b/.gitignore index fb20809..70da2df 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ node_modules/ .idea/ coverage/ docs/ +public/ +pages/ ts/*.js ts/*.js.map diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e22cf48..ccd25c4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,17 +1,16 @@ -image: hosttoday/ht-docker-node:npmts - +image: hosttoday/ht-docker-node:npmci stages: - test - release -- page - +- trigger +- pages testLEGACY: stage: test script: - npmci test legacy tags: - docker - + allow_failure: true testLTS: stage: test script: @@ -25,13 +24,30 @@ testSTABLE: - npmci test stable tags: - docker - release: stage: release script: - - npmci publish npm + - npmci publish + only: + - tags + tags: + - docker +trigger: + stage: trigger + script: - npmci trigger only: - tags tags: - docker +pages: + image: hosttoday/ht-docker-node:npmpage + stage: pages + script: + - npmci command npmpage --host gitlab + only: + - tags + artifacts: + expire_in: 1 week + paths: + - public \ No newline at end of file diff --git a/README.md b/README.md index 2c97c71..ee55205 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,21 @@ # gulp-function accepts call to execute in gulp pipeline. -### Status +## Availabililty +[![npm](https://push.rocks/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://push.rocks/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/) + +## Status for 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) [![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 Code](https://www.bithound.io/github/pushrocks/gulp-function/badges/code.svg)](https://www.bithound.io/github/pushrocks/gulp-function) -[![codecov.io](https://codecov.io/github/pushrocks/gulp-function/coverage.svg?branch=master)](https://codecov.io/github/pushrocks/gulp-function?branch=master) - -### Version -[![GitHub version](https://badge.fury.io/gh/pushrocks%2Fgulp-function.svg)](https://badge.fury.io/gh/pushrocks%2Fgulp-function) -[![npm version](https://badge.fury.io/js/gulp-function.svg)](https://badge.fury.io/js/gulp-function) +[![TypeScript](https://img.shields.io/badge/TypeScript-2.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/) ### Usage ```javascript @@ -18,7 +23,7 @@ var gulp = require("gulp"); var gulpFunction = require("gulp-function"); var Q = require("q"); -var myFunction = function () { +var myFunction = function (file, enc) { // file and enc are optional in case you want to modify the file object var done = Q.defer(); console.log("Hello World!") @@ -41,11 +46,14 @@ gulp.task('gulpTest',function() { ### 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. +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**!!! \ No newline at end of file + That means the stream's "finish" event fires **before "atLast" is executed**!!! + +[![npm](https://push.rocks/assets/repo-header.svg)](https://push.rocks) diff --git a/dist/gulpfunction.plugins.d.ts b/dist/gulpfunction.plugins.d.ts deleted file mode 100644 index 97d5ca8..0000000 --- a/dist/gulpfunction.plugins.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import "typings-global"; -export declare let Q: any; -export declare let through2: any; diff --git a/dist/gulpfunction.plugins.js b/dist/gulpfunction.plugins.js deleted file mode 100644 index 32a3d0f..0000000 --- a/dist/gulpfunction.plugins.js +++ /dev/null @@ -1,6 +0,0 @@ -"use strict"; -require("typings-global"); -exports.Q = require("q"); -exports.through2 = require("through2"); - -//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImd1bHBmdW5jdGlvbi5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFFYixTQUFDLEdBQUcsT0FBTyxDQUFDLEdBQUcsQ0FBQyxDQUFDO0FBQ2pCLGdCQUFRLEdBQUcsT0FBTyxDQUFDLFVBQVUsQ0FBQyxDQUFDIiwiZmlsZSI6Imd1bHBmdW5jdGlvbi5wbHVnaW5zLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFwidHlwaW5ncy1nbG9iYWxcIjtcclxuXHJcbmV4cG9ydCBsZXQgUSA9IHJlcXVpcmUoXCJxXCIpO1xyXG5leHBvcnQgbGV0IHRocm91Z2gyID0gcmVxdWlyZShcInRocm91Z2gyXCIpO1xyXG4iXX0= diff --git a/dist/index.d.ts b/dist/index.d.ts index 62d7805..09731ee 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -1 +1,5 @@ -import "typings-global"; +import 'typings-global'; +export declare type TExecutionMode = 'forEach' | 'forFirst' | 'atEnd'; +export interface IPromiseFunction { + (file?: any, enc?: any): PromiseLike; +} diff --git a/dist/index.js b/dist/index.js index 2dd3ec7..99ebd8e 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,56 +1,59 @@ "use strict"; require("typings-global"); -var plugins = require("./gulpfunction.plugins"); -module.exports = function (functionsToExecuteArg, executionModeArg) { - if (executionModeArg === void 0) { executionModeArg = 'forEach'; } - //important vars - var executionMode = executionModeArg; //can be forEach or atEnd - var functionsToExecute = functionsToExecuteArg; - var promiseArray = []; - var runFunction = function (functionArg) { - var returnValue = functionArg(); - if (typeof returnValue !== "undefined" && typeof returnValue.then !== "undefined") { +const q = require("q"); +const through2 = require("through2"); +module.exports = (functionsToExecuteArg, executionModeArg = 'forEach') => { + let promiseArray = []; + let runFunction = function (functionArg, file, enc) { + let returnValue = functionArg(file, enc); + if (typeof returnValue !== 'undefined' && typeof returnValue.then !== 'undefined') { promiseArray.push(returnValue); } }; - var checkAndRunFunction = function () { - if (typeof functionsToExecute === "function") { - runFunction(functionsToExecute); + let checkAndRunFunction = function (file, enc) { + if (typeof functionsToExecuteArg === 'function') { + runFunction(functionsToExecuteArg, file, enc); } - else if (Array.isArray(functionsToExecute)) { - for (var anyFunction in functionsToExecute) { - runFunction(functionsToExecute[anyFunction]); + else if (Array.isArray(functionsToExecuteArg)) { + for (let anyFunction in functionsToExecuteArg) { + runFunction(functionsToExecuteArg[anyFunction], file, enc); } } else { - throw new Error("gulp-callfunction: something is strange with the given arguments"); + throw new Error('gulp-callfunction: something is strange with the given arguments'); } - return plugins.Q.all(promiseArray); + return q.all(promiseArray); }; - var hasExecutedOnce = false; - var forEach = function (file, enc, cb) { - switch (executionMode) { - case "forEach": - checkAndRunFunction().then(function () { + let hasExecutedOnce = false; + let forEach = function (file, enc, cb) { + switch (executionModeArg) { + case 'forEach': + checkAndRunFunction(file, enc).then(function () { cb(null, file); }); break; - case "forFirst": - !hasExecutedOnce ? checkAndRunFunction().then(function () { + case 'forFirst': + if (hasExecutedOnce) { + checkAndRunFunction(file, enc) + .then(function () { + cb(null, file); + }); + } + else { cb(null, file); - }) : cb(null, file); + } hasExecutedOnce = true; break; - case "atEnd": + case 'atEnd': cb(null, file); break; default: break; } }; - var atEnd = function (cb) { - if (executionMode === "atEnd") { - checkAndRunFunction().then(function () { + let atEnd = function (cb) { + if (executionModeArg === 'atEnd') { + checkAndRunFunction(null, null).then(function () { cb(); }); } @@ -58,7 +61,6 @@ module.exports = function (functionsToExecuteArg, executionModeArg) { cb(); } }; - return plugins.through2.obj(forEach, atEnd); + return through2.obj(forEach, atEnd); }; - -//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFFeEIsSUFBTyxPQUFPLFdBQVcsd0JBQXdCLENBQUMsQ0FBQztBQUtuRCxNQUFNLENBQUMsT0FBTyxHQUFHLFVBQVUscUJBQStCLEVBQUMsZ0JBQW1DO0lBQW5DLGdDQUFtQyxHQUFuQyw0QkFBbUM7SUFDMUYsZ0JBQWdCO0lBQ2hCLElBQUksYUFBYSxHQUFHLGdCQUFnQixDQUFDLENBQUMseUJ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xuICAgICAgICAgICAgICAgIH0pO1xyXG4gICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgIGNhc2UgXCJmb3JGaXJzdFwiOlxyXG4gICAgICAgICAgICAgICAgIWhhc0V4ZWN1dGVkT25jZSA/IGNoZWNrQW5kUnVuRnVuY3Rpb24oKS50aGVuKGZ1bmN0aW9uKCl7XHJcbiAgICAgICAgICAgICAgICAgICAgY2IobnVsbCwgZmlsZSk7XHJcbiAgICAgICAgICAgICAgICB9KSA6IGNiKG51bGwsIGZpbGUpO1xyXG4gICAgICAgICAgICAgICAgaGFzRXhlY3V0ZWRPbmNlID0gdHJ1ZTtcclxuICAgICAgICAgICAgICAgIGJyZWFrO1xyXG4gICAgICAgICAgICBjYXNlIFwiYXRFbmRcIjpcclxuICAgICAgICAgICAgICAgIGNiKG51bGwsIGZpbGUpO1xyXG4gICAgICAgICAgICAgICAgYnJlYWs7XHJcbiAgICAgICAgICAgIGRlZmF1bHQ6XHJcbiAgICAgICAgICAgICAgICBicmVhaztcclxuICAgICAgICB9XHJcbiAgICB9O1xyXG5cclxuICAgIGxldCBhdEVuZCA9IGZ1bmN0aW9uKGNiKSB7XHJcbiAgICAgICAgaWYgKGV4ZWN1dGlvbk1vZGUgPT09IFwiYXRFbmRcIikge1xyXG4gICAgICAgICAgICBjaGVja0FuZFJ1bkZ1bmN0aW9uKCkudGhlbihmdW5jdGlvbigpe1xyXG4gICAgICAgICAgICAgICAgY2IoKTtcclxuICAgICAgICAgICAgfSk7XHJcbiAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgY2IoKTtcclxuICAgICAgICB9XHJcbiAgICB9O1xyXG4gICAgcmV0dXJuIHBsdWdpbnMudGhyb3VnaDIub2JqKGZvckVhY2gsYXRFbmQpO1xyXG59O1xyXG4iXX0= +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6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PO2dCQUNSLEVBQUUsQ0FBQyxJQUFJLEVBQUUsSUFBSSxDQUFDLENBQUE7Z0JBQ2QsS0FBSyxDQUFBO1lBQ1Q7Z0JBQ0ksS0FBSyxDQUFBO1FBQ2IsQ0FBQztJQUNMLENBQUMsQ0FBQTtJQUVELElBQUksS0FBSyxHQUFHLFVBQVUsRUFBRTtRQUNwQixFQUFFLENBQUMsQ0FBQyxnQkFBZ0IsS0FBSyxPQUFPLENBQUMsQ0FBQyxDQUFDO1lBQy9CLG1CQUFtQixDQUFDLElBQUksRUFBRSxJQUFJLENBQUMsQ0FBQyxJQUFJLENBQUM7Z0JBQ2pDLEVBQUUsRUFBRSxDQUFBO1lBQ1IsQ0FBQyxDQUFDLENBQUE7UUFDTixDQUFDO1FBQUMsSUFBSSxDQUFDLENBQUM7WUFDSixFQUFFLEVBQUUsQ0FBQTtRQUNSLENBQUM7SUFDTCxDQUFDLENBQUE7SUFDRCxNQUFNLENBQUMsUUFBUSxDQUFDLEdBQUcsQ0FBQyxPQUFPLEVBQUUsS0FBSyxDQUFDLENBQUE7QUFDdkMsQ0FBQyxDQUFBIn0= \ No newline at end of file diff --git a/npmextra.json b/npmextra.json new file mode 100644 index 0000000..916763c --- /dev/null +++ b/npmextra.json @@ -0,0 +1,5 @@ +{ + "npmts": { + "mode": "default" + } +} \ No newline at end of file diff --git a/npmts.json b/npmts.json deleted file mode 100644 index 85f70a8..0000000 --- a/npmts.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "mode":"default", - "coveralls":true -} \ No newline at end of file diff --git a/package.json b/package.json index 468d8cd..5f70900 100644 --- a/package.json +++ b/package.json @@ -26,14 +26,16 @@ }, "homepage": "https://gitlab.com/pushrocks/gulp-function", "dependencies": { + "@types/q": "0.0.32", + "@types/through2": "^2.0.31", "q": "^1.4.1", "through2": "^2.0.1", - "typings-global": "^1.0.3" + "typings-global": "^1.0.14" }, "devDependencies": { - "beautylog": "^5.0.8", + "beautylog": "^6.0.0", "gulp": "^3.9.1", - "npmts-g": "^5.2.6", - "typings-test": "^1.0.1" + "npmts-g": "^5.2.8", + "typings-test": "^1.0.3" } } diff --git a/test/test.js b/test/test.js index 50e19a6..1c741cd 100644 --- a/test/test.js +++ b/test/test.js @@ -45,7 +45,7 @@ var afterFunction = function () { done.resolve(); return done.promise; }; -var timeoutFunction = function () { +let timeoutFunction = function () { var done = Q.defer(); setTimeout(function () { beautylog.log("largeTimeout fired"); @@ -80,7 +80,7 @@ describe("gulpFunction", function () { }); it("should run in order", function (done) { this.timeout(5000); - var stream = gulp.src('./test/*.md') + let stream = gulp.src('./test/*.md') .pipe(gulpFunction([beforeFunction, middleFunction, middleFunction], 'atEnd')) .pipe(gulpFunction(function () { beautylog.log("stream progressed"); @@ -99,5 +99,4 @@ describe("gulpFunction", function () { }); }); }); - -//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FDUCxDQUFDLENBRG9CO0FBQ3JCLElBQUksSUFBSSxHQUFHLE9BQU8sQ0FBQyxNQUFNLENBQUMsQ0FBQztBQUMzQixJQUFJLFlBQVksR0FBRyxPQUFPLENBQUMsa0JBQWtCLENBQUMsQ0FBQztBQUMvQyxJQUFJLFNBQVMsR0FBRyxPQUFPLENBQUMsV0FBVyxDQUFDLENBQUM7QUFDckMsSUFBSSxDQUFDLEdBQUcsT0FBTyxDQUFDLEdBQUcsQ0FBQyxDQUFDO0FBRXJCLElBQUksVUFBVSxHQUFHO0lBQ2IsSUFBSSxJQUFJLEdBQUcsQ0FBQyxDQUFDLEtBQUssRUFBRSxDQUFBO0lBQ3BCLFNBQVMsQ0FBQyxHQUFHLENBQUMsbUJBQW1CLENBQUMsQ0FBQztJQUNuQyxJQUFJLENBQUMsT0FBTyxFQUFFLENBQUM7SUFDZixNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQztB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gICAgICAgLnBpcGUoZ3VscEZ1bmN0aW9uKFtiZWZvcmVGdW5jdGlvbixtaWRkbGVGdW5jdGlvbixtaWRkbGVGdW5jdGlvbl0sJ2F0RW5kJykpXHJcbiAgICAgICAgICAgIC5waXBlKGd1bHBGdW5jdGlvbihmdW5jdGlvbigpe1xyXG4gICAgICAgICAgICAgICAgYmVhdXR5bG9nLmxvZyhcInN0cmVhbSBwcm9ncmVzc2VkXCIpO1xyXG4gICAgICAgICAgICAgICAgdmFyIGRvbmUyID0gUS5kZWZlcigpO1xyXG4gICAgICAgICAgICAgICAgZG9uZTIucmVzb2x2ZSgpO1xyXG4gICAgICAgICAgICAgICAgcmV0dXJuIGRvbmUyLnByb21pc2U7XHJcbiAgICAgICAgICAgIH0sXCJmb3JFYWNoXCIpKVxyXG4gICAgICAgICAgICAucGlwZShndWxwRnVuY3Rpb24oZnVuY3Rpb24oKXtcclxuICAgICAgICAgICAgICAgIGJlYXV0eWxvZy5sb2coXCJuZXh0U3RlcFwiKTtcclxuICAgICAgICAgICAgfSkpXHJcbiAgICAgICAgICAgIC5waXBlKGd1bHBGdW5jdGlvbihhZnRlckZ1bmN0aW9uLFwiYXRFbmRcIikpXHJcbiAgICAgICAgICAgIC5waXBlKGd1bHBGdW5jdGlvbih0aW1lb3V0RnVuY3Rpb24sXCJhdEVuZFwiKSk7XHJcblxyXG4gICAgICAgIHN0cmVhbS5vbihcImZpbmlzaFwiLGZ1bmN0aW9uKCl7XHJcbiAgICAgICAgICAgIGJlYXV0eWxvZy5pbmZvKFwic3RyZWFtIGZpbmlzaGVkXCIpO1xyXG4gICAgICAgICAgICBkb25lKCk7XHJcbiAgICAgICAgfSk7XHJcbiAgICB9KTtcclxufSk7XHJcblxyXG4iXX0= +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtY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zthQUMxRSxJQUFJLENBQUMsWUFBWSxDQUFDO1lBQ2YsU0FBUyxDQUFDLEdBQUcsQ0FBQyxtQkFBbUIsQ0FBQyxDQUFDO1lBQ25DLElBQUksS0FBSyxHQUFHLENBQUMsQ0FBQyxLQUFLLEVBQUUsQ0FBQztZQUN0QixLQUFLLENBQUMsT0FBTyxFQUFFLENBQUM7WUFDaEIsTUFBTSxDQUFDLEtBQUssQ0FBQyxPQUFPLENBQUM7UUFDekIsQ0FBQyxFQUFDLFNBQVMsQ0FBQyxDQUFDO2FBQ1osSUFBSSxDQUFDLFlBQVksQ0FBQztZQUNmLFNBQVMsQ0FBQyxHQUFHLENBQUMsVUFBVSxDQUFDLENBQUM7UUFDOUIsQ0FBQyxDQUFDLENBQUM7YUFDRixJQUFJLENBQUMsWUFBWSxDQUFDLGFBQWEsRUFBQyxPQUFPLENBQUMsQ0FBQzthQUN6QyxJQUFJLENBQUMsWUFBWSxDQUFDLGVBQWUsRUFBQyxPQUFPLENBQUMsQ0FBQyxDQUFDO1FBRWpELE1BQU0sQ0FBQyxFQUFFLENBQUMsUUFBUSxFQUFDO1lBQ2YsU0FBUyxDQUFDLElBQUksQ0FBQyxpQkFBaUIsQ0FBQyxDQUFDO1lBQ2xDLElBQUksRUFBRSxDQUFDO1FBQ1gsQ0FBQyxDQUFDLENBQUM7SUFDUCxDQUFDLENBQUMsQ0FBQztBQUNQLENBQUMsQ0FBQyxDQUFDIn0= \ No newline at end of file diff --git a/ts/gulpfunction.plugins.ts b/ts/gulpfunction.plugins.ts deleted file mode 100644 index dbb7491..0000000 --- a/ts/gulpfunction.plugins.ts +++ /dev/null @@ -1,4 +0,0 @@ -import "typings-global"; - -export let Q = require("q"); -export let through2 = require("through2"); diff --git a/ts/index.ts b/ts/index.ts index 4058f82..302f00c 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -1,65 +1,75 @@ -import "typings-global"; +import 'typings-global' +import * as q from 'q' +import * as through2 from 'through2' +import { Transform } from 'stream' -import plugins = require("./gulpfunction.plugins"); +export type TExecutionMode = 'forEach' | 'forFirst' | 'atEnd' +export interface IPromiseFunction { + (file?, enc?): PromiseLike +} +module.exports = ( + functionsToExecuteArg: IPromiseFunction | IPromiseFunction[], + executionModeArg: TExecutionMode = 'forEach' +): Transform => { - -module.exports = function (functionsToExecuteArg:any|any[],executionModeArg:string = 'forEach') { - //important vars - let executionMode = executionModeArg; //can be forEach or atEnd - let functionsToExecute = functionsToExecuteArg; - let promiseArray = []; - let runFunction = function(functionArg){ - let returnValue = functionArg(); - if (typeof returnValue !== "undefined" && typeof returnValue.then !== "undefined") { - promiseArray.push(returnValue); + let promiseArray = [] + let runFunction = function (functionArg, file, enc) { + let returnValue = functionArg(file, enc) + if (typeof returnValue !== 'undefined' && typeof returnValue.then !== 'undefined') { + promiseArray.push(returnValue) } - }; + } - let checkAndRunFunction = function () { - if (typeof functionsToExecute === "function" ) { - runFunction(functionsToExecute); - } else if (Array.isArray(functionsToExecute)) { - for (let anyFunction in functionsToExecute) { - runFunction(functionsToExecute[anyFunction]); + let checkAndRunFunction = function (file, enc) { + if (typeof functionsToExecuteArg === 'function') { + runFunction(functionsToExecuteArg, file, enc) + } else if (Array.isArray(functionsToExecuteArg)) { + for (let anyFunction in functionsToExecuteArg) { + runFunction(functionsToExecuteArg[anyFunction], file, enc) } } else { - throw new Error("gulp-callfunction: something is strange with the given arguments"); + throw new Error('gulp-callfunction: something is strange with the given arguments') } - return plugins.Q.all(promiseArray); - }; + return q.all(promiseArray) + } - let hasExecutedOnce = false; - let forEach = function (file, enc, cb) { //the forEach function is called for every chunk - switch (executionMode){ - case "forEach": - checkAndRunFunction().then(function(){ - cb(null, file); - }); - break; - case "forFirst": - !hasExecutedOnce ? checkAndRunFunction().then(function(){ - cb(null, file); - }) : cb(null, file); - hasExecutedOnce = true; - break; - case "atEnd": - cb(null, file); - break; + let hasExecutedOnce = false + let forEach = function (file, enc, cb) { // the forEach function is called for every chunk + switch (executionModeArg) { + case 'forEach': + checkAndRunFunction(file, enc).then(function () { + cb(null, file) + }) + break + case 'forFirst': + if (hasExecutedOnce) { + checkAndRunFunction(file, enc) + .then(function () { + cb(null, file) + }) + } else { + cb(null, file) + } + hasExecutedOnce = true + break + case 'atEnd': + cb(null, file) + break default: - break; + break } - }; + } - let atEnd = function(cb) { - if (executionMode === "atEnd") { - checkAndRunFunction().then(function(){ - cb(); - }); + let atEnd = function (cb) { + if (executionModeArg === 'atEnd') { + checkAndRunFunction(null, null).then(function () { + cb() + }) } else { - cb(); + cb() } - }; - return plugins.through2.obj(forEach,atEnd); -}; + } + return through2.obj(forEach, atEnd) +} diff --git a/ts/tsd.json b/ts/tsd.json deleted file mode 100644 index ed09359..0000000 --- a/ts/tsd.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "version": "v4", - "repo": "borisyankov/DefinitelyTyped", - "ref": "master", - "path": "typings", - "bundle": "typings/tsd.d.ts", - "installed": { - "node/node.d.ts": { - "commit": "efa0c1196d7280640e624ac1e7fa604502e7bd63" - }, - "colors/colors.d.ts": { - "commit": "3191f6e0088eee07c4d8fd24e4d27a40a60d9eb9" - } - } -} diff --git a/tslint.json b/tslint.json new file mode 100644 index 0000000..45052ad --- /dev/null +++ b/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "tslint-config-standard" +}