2015-04-27 14 views
5

Sto provando eslint con gulp. Ho creato un compito come questo:Come eseguire gulp eslint in modo continuo e automatico durante il fissaggio dei file - come configurare l'orologio

  gulp.task('lint', function() { 
       return gulp.src([ 
      'components/myjs.js' 

           ]) 
        // eslint() attaches the lint output to the eslint property 
        // of the file object so it can be used by other modules. 
        .pipe(eslint()) 
        // 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 failOnError last. 
        .pipe(eslint.failOnError()); 
      }); 

quando corro gulp lint mi dice un sacco di errori. Ora sto provando a risolverli uno per uno. Ma devo rieseguire manualmente gulp lint affinché mi dia un rapporto aggiornato. Come posso configurarlo in modo che venga automaticamente riavviato ogni volta che aggiorno 'components/myjs.js'?

risposta

7

Basta aggiungere un compito orologio:

gulp.task('watch', function() { 
    gulp.watch('components/myjs.js', ['lint']); 
}); 

In questo modo Gulp sarà monitorare eventuali cambiamenti sul vostro 'components/myjs.js' ed eseguire il vostro compito 'lint' su ogni cambiamento

Se volete ulteriori letture: https://scotch.io/tutorials/automate-your-tasks-easily-with-gulp-js

+0

Grazie!! Ora ho appena eseguito gulp watch. – techguy2000

+0

Prego! :) –

Problemi correlati