javascript - Optimizing Gulp tasks -


i have following tasks part of gulp file:

gulp.task('jshint', function() {     return gulp.src(jssrc)         .pipe(jshint())         .pipe(jshint.reporter('jshint-stylish')); });  gulp.task('jscs', function() {     return gulp.src(jssrc)         .pipe(jscs()); });  gulp.task('jslint', [ 'jshint', 'jscs' ]); 

as understand it, if run jslint i'm not going benefit of reading disc one. that, have rewrite this:

gulp.task('jslint', function() {     return gulp.src(jssrc)         .pipe(jshint())         .pipe(jscs())         .pipe(jshint.reporter('jshint-stylish')); }); 

this fine, except doesn't allow me run jshint task independently of jscs if wanted to.

hence i'm wondering best practice around this? thinking break things out different functions , orchestrate things together, doesn't seem right approach.

a solution have seen , used is:

var merge = require('merge-stream');  gulp.task('analyze', function() {     var jshint = analyzejshint(config.js);     var jscs = analyzejscs(config.css);      return merge(jshint, jscs); });  function analyzejshint(sources, overridercfile) {     var jshintrcfile = overridercfile || './.jshintrc';     console.log('running jshint');     return gulp         .src(config.js)         .pipe(plug.jshint(jshintrcfile))         .pipe(plug.jshint.reporter('jshint-stylish')); }  function analyzejscs(sources, overridercfile) {     var jscsrcfile = overridercfile || './.jscsrc';     console.log('running jscs');     return gulp         .src(config.js)         .pipe(jscs(jscsrcfile)) } 

if wanted perform one, can return stream 1 of functions instead.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

c# - How do I get the Nth largest element from a list with duplicates, using LINQ? -

jsp - "Sending a redirect is forbidden after the response has been committed" in sendRedirect -