Reputation: 10496
I have situation where i'm building minified script through gulp, from scripts that are either vendor scripts or my scripts, something like:
var paths = {
public : './public/javascripts',
api : './public/API',
vendor : './public/vendor',
destination : './dist'
};
gulp.task('scripts-out', function() {
gulp.src([
paths.public + '/a.js',
paths.public + '/b.js',
paths.public + '/c.js',
paths.public + '/d.js',
paths.api + '/e.js',
paths.public + '/f.js'
])
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(concat('out.js'))
.pipe(gulp.dest(paths.destination + '/javascripts'));
});
Only e.js
is not vendor script and only that script should go through jshint(), from official documentation of the plugin i can't see solution for this.
I tried passing config
object to jshint(), something like:
pipe(jshint({
files: paths.api + '/e.js'
}))
That was just speculation which don't work. Side question of this how to force jshint to write results to some file instead of console?
EDIT: FIND SOLUTION
I find the way through the .jshintignore
file, which should be in the root of the project, for example if you want to ignore all from the vendor folder you can just add one line to .jshintignore
file: public/src/vendor/*
Upvotes: 4
Views: 1740
Reputation: 10104
You could use gulp-filter to filter which files get passed to jshint
:
var gulpFilter = require('gulp-filter');
var filter = gulpFilter([paths.public + '/e.js']);
gulp.task('scripts-out', function() {
return gulp.src([
paths.public + '/a.js',
paths.public + '/b.js',
paths.public + '/c.js',
paths.public + '/d.js',
paths.api + '/e.js',
paths.public + '/f.js'
])
.pipe(filter)
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(filter.restore())
.pipe(concat('out.js'))
.pipe(gulp.dest(paths.destination + '/javascripts'));
});
New version(3.0.1) has interface updates:
// you should pass {restore: true} for restore ability
var filter = gulpFilter([paths.public + '/e.js'], {restore: true});
...
// filter.restore is now object, not a method
.pipe(filter.restore)
Upvotes: 3