OverZealous / run-sequence

Run a series of dependent gulp tasks in order
MIT License
961 stars 56 forks source link

ESLintError in plugin 'gulp-eslint' #85

Closed nodox closed 7 years ago

nodox commented 7 years ago

Once I introduced run-sequence my build started to break with eslint. Not sure who this problem belongs too. Below is my code. I'm trying to run my tests and lint my code in series.

const gulp = require('gulp');
const eslint = require('gulp-eslint');
const mocha = require('gulp-mocha');
const gutil = require('gulp-util');
const runSequence = require('run-sequence').use(gulp);

const srcFiles = ['src/*.js', 'test/*.spec.js'];

gulp.task('lint', () => {
    // ESLint ignores files with "node_modules" paths.
    // So, it's best to have gulp ignore the directory as well.
    // Also, Be sure to return the stream from the task;
    // Otherwise, the task may end before the stream has finished.
    return gulp.src(srcFiles)
        // eslint() attaches the lint output to the "eslint" property
        // of the file object so it can be used by other modules.
        .pipe(eslint({ useEslintrc: true }))
        // eslint.format() outputs the lint results to the console.
        // Alternatively use eslint.formatEach() (see Docs).
        .pipe(eslint.format())
        // To have the process exit with an error code (1) on
        // lint error, return the stream and pipe to failAfterError last.
        .pipe(eslint.failAfterError());
});

gulp.task('mocha', () => {
    return gulp
        .src('test/server/*.js', { read: false })
        .pipe(mocha({ reporter:'spec'}))

        .on('error', gutil.log);
});

gulp.task('default', () => {
      gulp.watch(['src/**', 'test/**'],  runSequence('mocha', 'lint'));
});
OverZealous commented 7 years ago

First, what's the error? You never said what's not working.

Second, your gulp.watch line makes no sense. You are running the sequence immediately, and only once. For example, if you had said gulp.watch(/* ... */, console.log('hello')), you'd see hello printed once, and then nothing else.

I doubt this is an issue with run-sequence. All this library does is call Gulp tasks one after the other.