Get rid of needless boilerplate noise and just focus on the stuff that changes.
Turn this (195 non-space characters):
return gulp.src(paths.scripts)
.pipe(sourcemaps.init())
.pipe(to5())
.pipe(concat('index.js'))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(paths.dist))
.on('error', function(e) { console.log(e); });
Into this (175 non-space characters):
return pipe([
gulp.src(paths.scripts)
,sourcemaps.init()
,to5()
,concat('index.js')
,sourcemaps.write('.')
,gulp.dest(paths.dist)
])
.on('error', function(e) { console.log(e); });
Or this:
return pipe(gulp.src(paths.scripts),
[
sourcemaps.init(),
to5(),
concat('index.js'),
sourcemaps.write('.'),
gulp.dest(paths.dist)
])
.on('error', function(e) {console.log(e);});
module.exports = function pipe(stream, tubes) {
tubes = tubes || stream.slice(1);
return tubes.reduce(function(stream, tube) { return stream.pipe(tube); }, Array.isArray(stream) ? stream[0] : stream);
};
npm install --save gulp-pipe
- Investigate flows for allowing inline
.on
, as in this example.
- This library is not specific to, nor has dependencies on, gulp. It will work for any Streams, however it was created to simplify my
gulpfile.js
's