Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
c1f1500ffc | |||
e42c5004c2 | |||
e0c4a10411 | |||
6deab0541f | |||
22e3dc6136 | |||
e69e8df875 | |||
4cb24a4a6d | |||
ebac042791 | |||
d8fc992ba3 | |||
82def89388 | |||
4b832bbf95 | |||
cf8182b86a | |||
c708f964ec | |||
f9c4fb9887 | |||
c6c352f587 | |||
3930912f25 | |||
b6a6c62962 | |||
e43c627307 |
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
node_modules/
|
||||||
|
.settings/
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
ts/*.js
|
||||||
|
ts/*.js.map
|
@ -10,7 +10,7 @@ deploy:
|
|||||||
provider: npm
|
provider: npm
|
||||||
email: npm@smart-coordination.com
|
email: npm@smart-coordination.com
|
||||||
api_key:
|
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:
|
on:
|
||||||
tags: true
|
tags: true
|
||||||
repo: pushrocks/gulp-callfunction
|
repo: pushrocks/gulp-callfunction
|
||||||
|
26
README.md
Normal file
26
README.md
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# gulp-callfunction
|
||||||
|
accepts call to execute in gulp pipeline.
|
||||||
|
|
||||||
|
### build status/Dependencies
|
||||||
|
[](https://travis-ci.org/pushrocks/gulp-callfunction)
|
||||||
|
[](https://david-dm.org/pushrocks/gulp-callfunction)
|
||||||
|
[](https://david-dm.org/pushrocks/gulp-callfunction#info=devDependencies)
|
||||||
|
|
||||||
|
### Usage
|
||||||
|
```javascript
|
||||||
|
var gulp = require("gulp");
|
||||||
|
var gulpCallFunction = require("gulp-callfunction");
|
||||||
|
|
||||||
|
var myFunction = function () {
|
||||||
|
console.log("Hello World!")
|
||||||
|
}
|
||||||
|
|
||||||
|
gulp.task('gulpTest',function() {
|
||||||
|
gulp.src('./mydir/*.something')
|
||||||
|
.pipe(gulpCallFunction(myFunction,'forEach'))
|
||||||
|
.pipe(gulp.dest("./build/"))
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
>Note: The first argument of gulpCallFunction can also be an array of multiple functionnames.
|
||||||
|
>Note: the second argument can be empty (defaults to 'forEach') or 'atEnd'
|
48
index.js
Normal file
48
index.js
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/// <reference path="typings/tsd.d.ts" />
|
||||||
|
var through = require("through2");
|
||||||
|
var path = require("path");
|
||||||
|
var beautylog = require("beautylog")("os");
|
||||||
|
module.exports = function (functionsToExecute, executionMode, logBool) {
|
||||||
|
if (executionMode === void 0) { executionMode = 'forEach'; }
|
||||||
|
if (logBool === void 0) { logBool = false; }
|
||||||
|
//important vars
|
||||||
|
var gulpCallFunction = {
|
||||||
|
executionMode: 'forEach',
|
||||||
|
functionsToExecute: undefined,
|
||||||
|
logBool: false
|
||||||
|
};
|
||||||
|
gulpCallFunction.functionsToExecute = functionsToExecute;
|
||||||
|
gulpCallFunction.executionMode = executionMode;
|
||||||
|
gulpCallFunction.logBool = logBool;
|
||||||
|
var runFunctionNames = function () {
|
||||||
|
if (typeof gulpCallFunction.functionsToExecute == "function") {
|
||||||
|
gulpCallFunction.functionsToExecute();
|
||||||
|
}
|
||||||
|
else if (Array.isArray(gulpCallFunction.functionsToExecute)) {
|
||||||
|
for (var anyFunction in gulpCallFunction.functionsToExecute) {
|
||||||
|
anyFunction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
beautylog.error('gulp-callfunction: something is strange with the given arguments');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var forEach = function (file, enc, cb) {
|
||||||
|
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 (cb) {
|
||||||
|
if (gulpCallFunction.executionMode == "atEnd") {
|
||||||
|
runFunctionNames();
|
||||||
|
}
|
||||||
|
cb();
|
||||||
|
};
|
||||||
|
return through.obj(forEach, atEnd);
|
||||||
|
};
|
17
package.json
17
package.json
@ -1,10 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "gulp-callfunction",
|
"name": "gulp-callfunction",
|
||||||
"version": "0.0.2",
|
"version": "0.0.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": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"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)"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -20,5 +23,13 @@
|
|||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/pushrocks/gulp-callfunction/issues"
|
"url": "https://github.com/pushrocks/gulp-callfunction/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/pushrocks/gulp-callfunction"
|
"homepage": "https://github.com/pushrocks/gulp-callfunction",
|
||||||
|
"devDependencies": {
|
||||||
|
"gulp": "^3.9.0",
|
||||||
|
"gulp-typescript": "^2.9.2"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"beautylog": "1.0.4",
|
||||||
|
"through2": "^2.0.0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
13
test.js
Normal file
13
test.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
/// <reference path="typings/tsd.d.ts" />
|
||||||
|
var gulp = require("gulp");
|
||||||
|
var gulpCallFunction = require("./index.js");
|
||||||
|
var beautylog = require("beautylog")("os");
|
||||||
|
var myFunction = function () {
|
||||||
|
beautylog.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
2
test/README.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#Test
|
||||||
|
This directory contains files for testing
|
2
test/result/test.md
Normal file
2
test/result/test.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# Test.md
|
||||||
|
This is a test file for the test.js gulp pipeline
|
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
|
@ -11,6 +11,16 @@ gulp.task('compileTS', function() {
|
|||||||
return stream;
|
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');
|
console.log('Typescript compiled');
|
||||||
});
|
});
|
||||||
|
gulp.start.apply(gulp, ['default']);
|
45
ts/index.ts
45
ts/index.ts
@ -1,14 +1,45 @@
|
|||||||
/// <reference path="typings/tsd.d.ts" />
|
/// <reference path="typings/tsd.d.ts" />
|
||||||
var path, through;
|
var through = require("through2");
|
||||||
|
var path = require("path");
|
||||||
|
var beautylog = require("beautylog")("os");
|
||||||
|
|
||||||
through = require("through2");
|
|
||||||
path = require("path");
|
|
||||||
|
|
||||||
module.exports = (jsonObject,type = undefined) => {
|
module.exports = function (functionsToExecuteArg:any|any[],executionModeArg:string = 'forEach', logBoolArg = false) {
|
||||||
|
//important vars
|
||||||
|
var gulpCallFunction = {
|
||||||
|
executionMode: executionModeArg, //can be forEach or atEnd
|
||||||
|
functionsToExecute: functionsToExecuteArg,
|
||||||
|
logBool: logBoolArg
|
||||||
|
};
|
||||||
|
|
||||||
return through.obj((file, enc, cb) => {
|
var runFunctionNames = function () {
|
||||||
|
if (typeof gulpCallFunction.functionsToExecute == "function" ) {
|
||||||
|
gulpCallFunction.functionsToExecute();
|
||||||
|
} else if (Array.isArray(gulpCallFunction.functionsToExecute)) {
|
||||||
|
for (var anyFunction in gulpCallFunction.functionsToExecute) {
|
||||||
|
anyFunction();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
beautylog.error('gulp-callfunction: something is strange with the given arguments');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
var forEach = function (file, enc, cb) {
|
||||||
|
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
|
//tell gulp that we are complete
|
||||||
return cb(null, file);
|
return cb(null, file);
|
||||||
});
|
};
|
||||||
|
|
||||||
|
var atEnd = function(cb) {
|
||||||
|
if (gulpCallFunction.executionMode == "atEnd") {
|
||||||
|
runFunctionNames();
|
||||||
|
}
|
||||||
|
cb();
|
||||||
|
};
|
||||||
|
return through.obj(forEach,atEnd);
|
||||||
};
|
};
|
||||||
|
15
ts/test.ts
Normal file
15
ts/test.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
/// <reference path="typings/tsd.d.ts" />
|
||||||
|
var gulp = require("gulp");
|
||||||
|
var gulpCallFunction = require("./index.js");
|
||||||
|
var beautylog = require("beautylog")("os");
|
||||||
|
|
||||||
|
var myFunction = function () {
|
||||||
|
beautylog.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']);
|
@ -7,6 +7,9 @@
|
|||||||
"installed": {
|
"installed": {
|
||||||
"node/node.d.ts": {
|
"node/node.d.ts": {
|
||||||
"commit": "efa0c1196d7280640e624ac1e7fa604502e7bd63"
|
"commit": "efa0c1196d7280640e624ac1e7fa604502e7bd63"
|
||||||
|
},
|
||||||
|
"colors/colors.d.ts": {
|
||||||
|
"commit": "3191f6e0088eee07c4d8fd24e4d27a40a60d9eb9"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
123
ts/typings/colors/colors.d.ts
vendored
Normal file
123
ts/typings/colors/colors.d.ts
vendored
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
// Type definitions for Colors.js 0.6.0-1
|
||||||
|
// Project: https://github.com/Marak/colors.js
|
||||||
|
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||||
|
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||||
|
|
||||||
|
declare module "colors" {
|
||||||
|
interface Color {
|
||||||
|
(text: string): string;
|
||||||
|
|
||||||
|
black: Color;
|
||||||
|
red: Color;
|
||||||
|
green: Color;
|
||||||
|
yellow: Color;
|
||||||
|
blue: Color;
|
||||||
|
magenta: Color;
|
||||||
|
cyan: Color;
|
||||||
|
white: Color;
|
||||||
|
gray: Color;
|
||||||
|
grey: Color;
|
||||||
|
|
||||||
|
bgBlack: Color;
|
||||||
|
bgRed: Color;
|
||||||
|
bgGreen: Color;
|
||||||
|
bgYellow: Color;
|
||||||
|
bgBlue: Color;
|
||||||
|
bgMagenta: Color;
|
||||||
|
bgCyan: Color;
|
||||||
|
bgWhite: Color;
|
||||||
|
|
||||||
|
reset: Color;
|
||||||
|
bold: Color;
|
||||||
|
dim: Color;
|
||||||
|
italic: Color;
|
||||||
|
underline: Color;
|
||||||
|
inverse: Color;
|
||||||
|
hidden: Color;
|
||||||
|
strikethrough: Color;
|
||||||
|
|
||||||
|
rainbow: Color;
|
||||||
|
zebra: Color;
|
||||||
|
america: Color;
|
||||||
|
trap: Color;
|
||||||
|
random: Color;
|
||||||
|
}
|
||||||
|
|
||||||
|
module e {
|
||||||
|
export function setTheme(theme:any): void;
|
||||||
|
|
||||||
|
export var black: Color;
|
||||||
|
export var red: Color;
|
||||||
|
export var green: Color;
|
||||||
|
export var yellow: Color;
|
||||||
|
export var blue: Color;
|
||||||
|
export var magenta: Color;
|
||||||
|
export var cyan: Color;
|
||||||
|
export var white: Color;
|
||||||
|
export var gray: Color;
|
||||||
|
export var grey: Color;
|
||||||
|
|
||||||
|
export var bgBlack: Color;
|
||||||
|
export var bgRed: Color;
|
||||||
|
export var bgGreen: Color;
|
||||||
|
export var bgYellow: Color;
|
||||||
|
export var bgBlue: Color;
|
||||||
|
export var bgMagenta: Color;
|
||||||
|
export var bgCyan: Color;
|
||||||
|
export var bgWhite: Color;
|
||||||
|
|
||||||
|
export var reset: Color;
|
||||||
|
export var bold: Color;
|
||||||
|
export var dim: Color;
|
||||||
|
export var italic: Color;
|
||||||
|
export var underline: Color;
|
||||||
|
export var inverse: Color;
|
||||||
|
export var hidden: Color;
|
||||||
|
export var strikethrough: Color;
|
||||||
|
|
||||||
|
export var rainbow: Color;
|
||||||
|
export var zebra: Color;
|
||||||
|
export var america: Color;
|
||||||
|
export var trap: Color;
|
||||||
|
export var random: Color;
|
||||||
|
}
|
||||||
|
|
||||||
|
export = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface String {
|
||||||
|
black: string;
|
||||||
|
red: string;
|
||||||
|
green: string;
|
||||||
|
yellow: string;
|
||||||
|
blue: string;
|
||||||
|
magenta: string;
|
||||||
|
cyan: string;
|
||||||
|
white: string;
|
||||||
|
gray: string;
|
||||||
|
grey: string;
|
||||||
|
|
||||||
|
bgBlack: string;
|
||||||
|
bgRed: string;
|
||||||
|
bgGreen: string;
|
||||||
|
bgYellow: string;
|
||||||
|
bgBlue: string;
|
||||||
|
bgMagenta: string;
|
||||||
|
bgCyan: string;
|
||||||
|
bgWhite: string;
|
||||||
|
|
||||||
|
reset: string;
|
||||||
|
bold: string;
|
||||||
|
dim: string;
|
||||||
|
italic: string;
|
||||||
|
underline: string;
|
||||||
|
inverse: string;
|
||||||
|
hidden: string;
|
||||||
|
strikethrough: string;
|
||||||
|
|
||||||
|
rainbow: string;
|
||||||
|
zebra: string;
|
||||||
|
america: string;
|
||||||
|
trap: string;
|
||||||
|
random: string;
|
||||||
|
}
|
1
ts/typings/tsd.d.ts
vendored
1
ts/typings/tsd.d.ts
vendored
@ -1 +1,2 @@
|
|||||||
/// <reference path="node/node.d.ts" />
|
/// <reference path="node/node.d.ts" />
|
||||||
|
/// <reference path="colors/colors.d.ts" />
|
||||||
|
Reference in New Issue
Block a user