Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit correct exit code on Sass compilation errors if env != development #19

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions tasks/browsersync.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ function browsersync(gulp, $, config, css, js) {
open: false
});

// set a config param to signal browserSync is active;
// styles.js will suppress errors for this env to avoid
// the watch process exiting on errors
config.livereload = true;

gulp.watch(config.styles.watch, { usePolling: true }, css);
gulp.watch(config.scripts.watch, { usePolling: true }, js);
}
Expand Down
9 changes: 8 additions & 1 deletion tasks/styles.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const PluginError = require('plugin-error');

function styles(gulp, $, config) {
// take the array and map over each script config object in it
const tasks = config.styles.files.map((stylesheet) => {
Expand All @@ -15,7 +17,12 @@ function styles(gulp, $, config) {
pipeStdout: true,
sassOutputStyle: 'nested',
includePaths: config.styles.includePaths ? config.styles.includePaths : [config.npmdir]
}).on('error', $.sass.logError))
}).on('error', function(error) {
const message = new PluginError('sass', error.messageFormatted).toString();
process.stderr.write(`${message}\n`);
config.livereload ? $.through2.obj() : process.exitCode = 1;
done();
}))
.pipe($.postcss(config.styles.postCssPlugins(config, stylesheet)))
.pipe($.concat(stylesheet.name))
.pipe($.cleanCss({
Expand Down