now working
This commit is contained in:
parent
b6a6c62962
commit
3930912f25
22
README.md
22
README.md
@ -1,5 +1,25 @@
|
|||||||
# gulp-callfunction
|
# gulp-callfunction
|
||||||
accepts call to execute in gulp pipeline.
|
accepts call to execute in gulp pipeline.
|
||||||
|
|
||||||
## build status
|
### build status/Dependencies
|
||||||
[![Build Status](https://travis-ci.org/pushrocks/gulp-callfunction.svg?branch=v0.0.2)](https://travis-ci.org/pushrocks/gulp-callfunction)
|
[![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)
|
||||||
|
|
||||||
|
### 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'
|
45
index.js
45
index.js
@ -1,11 +1,38 @@
|
|||||||
/// <reference path="typings/tsd.d.ts" />
|
/// <reference path="typings/tsd.d.ts" />
|
||||||
var path, through;
|
var through = require("through2");
|
||||||
through = require("through2");
|
var path = require("path");
|
||||||
path = require("path");
|
var beautylog = require("beautylog");
|
||||||
module.exports = function (jsonObject, type) {
|
//important vars
|
||||||
if (type === void 0) { type = undefined; }
|
var executionMode; //can be forEach or atEnd
|
||||||
return through.obj(function (file, enc, cb) {
|
var functionsToExecute;
|
||||||
//tell gulp that we are complete
|
var runFunctionNames = function () {
|
||||||
return cb(null, file);
|
if (typeof functionsToExecute === "function") {
|
||||||
});
|
functionsToExecute();
|
||||||
|
}
|
||||||
|
else if (Array.isArray(functionsToExecute)) {
|
||||||
|
for (var anyFunction in functionsToExecute) {
|
||||||
|
anyFunction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
beautylog.error('gulp-callfunction: something is strange with the given arguments');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var forEach = function (file, enc, cb) {
|
||||||
|
if (executionMode === 'forEach') {
|
||||||
|
runFunctionNames();
|
||||||
|
}
|
||||||
|
//tell gulp that we are complete
|
||||||
|
return cb(null, file);
|
||||||
|
};
|
||||||
|
var atEnd = function () {
|
||||||
|
if (executionMode === "atEnd") {
|
||||||
|
runFunctionNames();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
module.exports = function (functionsToExecute, executionMode) {
|
||||||
|
if (executionMode === void 0) { executionMode = 'forEach'; }
|
||||||
|
this.functionsToExecute = functionsToExecute;
|
||||||
|
this.executionMode = executionMode;
|
||||||
|
return through.obj(forEach, atEnd);
|
||||||
};
|
};
|
||||||
|
41
npm-debug.log
Normal file
41
npm-debug.log
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
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 ]
|
@ -27,5 +27,8 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"gulp": "^3.9.0",
|
"gulp": "^3.9.0",
|
||||||
"gulp-typescript": "^2.9.2"
|
"gulp-typescript": "^2.9.2"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"beautylog": "0.0.15"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
39
ts/index.ts
39
ts/index.ts
@ -1,14 +1,39 @@
|
|||||||
/// <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");
|
||||||
|
|
||||||
through = require("through2");
|
//important vars
|
||||||
path = require("path");
|
var executionMode:string; //can be forEach or atEnd
|
||||||
|
var functionsToExecute;
|
||||||
module.exports = (jsonObject,type = undefined) => {
|
var runFunctionNames = function () {
|
||||||
|
if (typeof functionsToExecute === "function" ) {
|
||||||
|
functionsToExecute();
|
||||||
|
} else if (Array.isArray(functionsToExecute)) {
|
||||||
|
for (var anyFunction in functionsToExecute) {
|
||||||
|
anyFunction();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
beautylog.error('gulp-callfunction: something is strange with the given arguments');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
return through.obj((file, enc, cb) => {
|
var forEach = function (file, enc, cb) {
|
||||||
|
if (executionMode === '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() {
|
||||||
|
if (executionMode === "atEnd") {
|
||||||
|
runFunctionNames();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
module.exports = function (functionsToExecute:any|any[],executionMode:string = 'forEach') {
|
||||||
|
this.functionsToExecute = functionsToExecute;
|
||||||
|
this.executionMode = executionMode;
|
||||||
|
return through.obj(forEach,atEnd);
|
||||||
};
|
};
|
||||||
|
@ -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" />
|
||||||
|
Loading…
Reference in New Issue
Block a user