Compare commits

..

4 Commits

Author SHA1 Message Date
cb60bec110 2.2.3 2016-12-04 21:33:05 +01:00
291583b17a update tests 2016-12-04 21:32:56 +01:00
9d54da207f 2.2.2 2016-11-25 11:21:59 +01:00
7aad993847 improve README 2016-11-25 11:21:55 +01:00
4 changed files with 36 additions and 7 deletions

View File

@ -39,7 +39,7 @@ let myFunction = function (file, enc) { // file and enc are optional in case you
gulp.task('gulpTest',function() { gulp.task('gulpTest',function() {
let stream = gulp.src('./mydir/*.something') let stream = gulp.src('./mydir/*.something')
.pipe(gulpFunction(myFunction,'forEach')) //read the notes below .pipe(gulpFunction(myFunction,'forEach')) //read the notes below
// .pipe(gulpFunction.forEach(myFunction)) // .pipe(forEach(myFunction)) // if imported as >> import { forEach } from 'gulp-function' <<
.pipe(gulp.dest("./build/")); .pipe(gulp.dest("./build/"));
return stream; // by returning the stream gulp knows when our task has finished. return stream; // by returning the stream gulp knows when our task has finished.
}); });

View File

@ -1,6 +1,6 @@
{ {
"name": "gulp-function", "name": "gulp-function",
"version": "2.2.1", "version": "2.2.3",
"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",

File diff suppressed because one or more lines are too long

View File

@ -11,7 +11,7 @@ let myFunction = function () {
done.resolve() done.resolve()
return done.promise return done.promise
} }
let myFunction2 = function () { let myFunction2 = function (file?) {
let done = Q.defer() let done = Q.defer()
beautylog.ok('Function2 executed') beautylog.ok('Function2 executed')
done.resolve() done.resolve()
@ -31,6 +31,18 @@ let beforeFunction = function () {
return done.promise return done.promise
} }
let logFileFunction = function (file) {
let done = Q.defer()
console.log(file.contents)
if (typeof file.contents !== 'undefined') {
} else {
throw new Error('file.contents not present')
}
done.resolve()
return done.promise
}
let middleFunctionRun = false let middleFunctionRun = false
let middleFunction = function () { let middleFunction = function () {
@ -65,7 +77,7 @@ let timeoutFunction = function(){
describe('gulpFunction',function(){ describe('gulpFunction',function(){
it('should run through smoothly with ' + "'forEach'",function(done){ it('should run through smoothly with ' + "'forEach'",function(done){
gulp.src('./test/*.md') gulp.src('./test/*.md')
.pipe(gulpFunction(myFunction,'forEach')) .pipe(gulpFunction(logFileFunction,'forEach'))
.pipe(gulp.dest('./test/result/')) .pipe(gulp.dest('./test/result/'))
gulp.src('./test/*.md') gulp.src('./test/*.md')
@ -105,7 +117,10 @@ describe('gulpFunction',function(){
return done2.promise return done2.promise
},'forEach')) },'forEach'))
.pipe(gulpFunction(function(){ .pipe(gulpFunction(function(){
let done = Q.defer()
beautylog.log('nextStep') beautylog.log('nextStep')
done.resolve()
return done.promise
})) }))
.pipe(gulpFunction(afterFunction,'atEnd')) .pipe(gulpFunction(afterFunction,'atEnd'))
.pipe(gulpFunction(timeoutFunction,'atEnd')) .pipe(gulpFunction(timeoutFunction,'atEnd'))