Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
cb60bec110 | |||
291583b17a | |||
9d54da207f | |||
7aad993847 |
@ -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.
|
||||||
});
|
});
|
||||||
|
@ -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",
|
||||||
|
20
test/test.js
20
test/test.js
File diff suppressed because one or more lines are too long
19
test/test.ts
19
test/test.ts
@ -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'))
|
||||||
|
Reference in New Issue
Block a user