From fabd7e258ba5763587c105c4d0dec7d985092a11 Mon Sep 17 00:00:00 2001 From: Benedikt Werner <1benediktwerner@gmail.com> Date: Wed, 8 Sep 2021 05:33:07 +0200 Subject: [PATCH] ui/gulp: Induce non-zero exit status when sass build fails --- ui/gulpfile.js | 14 +++++++++----- ui/package.json | 3 ++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/ui/gulpfile.js b/ui/gulpfile.js index 3d11cb66fe..89734843ac 100644 --- a/ui/gulpfile.js +++ b/ui/gulpfile.js @@ -1,5 +1,6 @@ const gulp = require('gulp'); const sass = require('gulp-sass')(require('node-sass')); +const PluginError = require('plugin-error'); const sourcemaps = require('gulp-sourcemaps'); const autoprefixer = require('gulp-autoprefixer'); const sassInheritance = require('gulp-sass-inheritance'); @@ -31,18 +32,21 @@ const build = () => //filter out internal imports (folders and files starting with "_" ) .pipe(filter(file => !/\/_/.test(file.path) || !/^_/.test(file.relative))) .pipe(sourcemaps.init()) - .pipe(sass(sassOptions).on('error', sass.logError)) + .pipe( + sass(sassOptions).on('error', err => { + throw new PluginError('sass', err.messageFormatted, { showProperties: false }); + }) + ) .pipe(sourcemaps.write()) .pipe(renameAs('dev')) .pipe(destination()); -const setWatching = async () => { +const startWatching = () => { global.isWatching = true; + gulp.watch(sourcesGlob, { ignoreInitial: false }, build); }; -const startWatching = () => gulp.watch(sourcesGlob, build); - -gulp.task('css', gulp.series([createThemedBuilds, setWatching, build, startWatching])); +gulp.task('css', gulp.series([createThemedBuilds, startWatching])); gulp.task('css-dev', gulp.series([createThemedBuilds, build])); diff --git a/ui/package.json b/ui/package.json index 53fbe98204..ae45908bd8 100644 --- a/ui/package.json +++ b/ui/package.json @@ -22,7 +22,8 @@ "gulp-sass-inheritance": "^1.1", "breakpoint-sass": "^2.7.1", "gulp-size": "^4.0.1", - "gulp-sourcemaps": "^3.0.0" + "gulp-sourcemaps": "^3.0.0", + "plugin-error": "^1.0.1" }, "scripts": { "gulp": "gulp"