Skip to content

Commit

Permalink
npm run gulp survit en cas d’erreur
Browse files Browse the repository at this point in the history
Avant, `npm run gulp` crashait bêtement lorsqu’on oubliait un `;` dans
le CSS. Pas terrible.

Avec ce patch, il continue d’observer les fichiers. Notez que `npm run
build` quitte toujours comme il faut (avec un statut non nul) en cas
d’erreur (sinon ça serait pas cool pour la CI).

C’est un peu cochon mais Gulp est assez pété “by design”. Si quelqu’un
a une meilleure solution, je suis preneur.
  • Loading branch information
motet-a committed Aug 2, 2017
1 parent 191099d commit dc76439
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion Gulpfile.js
Expand Up @@ -120,7 +120,7 @@ gulp.task('images', ['css:sprite'], () =>
.pipe(gulp.dest('dist/')));

// Watch for file changes
gulp.task('watch', ['build'], () => {
gulp.task('watch-runner', () => {
gulp.watch('assets/js/*.js', ['js']);
gulp.watch(['assets/{images,smileys}/**/*', '!assets/images/sprite*.png'], ['images']);
gulp.watch(['assets/scss/**/*.scss', '!assets/scss/_sprite.scss'], ['css']);
Expand All @@ -134,6 +134,30 @@ gulp.task('watch', ['build'], () => {
livereload.listen();
});

// https://github.com/gulpjs/gulp/issues/259#issuecomment-152177973
gulp.task('watch', cb => {
function spawnGulp(args) {
return require('child_process')
.spawn(
'node_modules/.bin/gulp',
args,
{stdio: 'inherit'}
)
}

function spawnBuild() {
return spawnGulp(['build'])
.on('close', spawnWatch)
}

function spawnWatch() {
return spawnGulp(['watch-runner'])
.on('close', spawnWatch)
}

spawnBuild();
});

// Compiles errors' CSS
gulp.task('errors', () =>
gulp.src('errors/scss/main.scss')
Expand Down

0 comments on commit dc76439

Please sign in to comment.