Larry Lawless
Larry Lawless

Reputation: 623

gulp-ruby-sass plugin not throwing error, only logging the error itself

On the page for gulp ruby sass https://www.npmjs.com/package/gulp-ruby-sass/

It says "Handle Sass errors with an on('error', cb) listener. gulp-ruby-sass throws errors like a gulp plugin, but streams the erroring files so you can see Sass errors in your browser too."

Then I should be able to log the error that it says it throws but when an error happens it is logged to the console and my error callback is never invoked, this is my code:

gulp.task("css", function() {

   return sass(paths.css.in)
          .on('error', logError)
          .pipe(gulp.dest(paths.css.out));

});

Am I doing something wrong?

Upvotes: 0

Views: 202

Answers (1)

RobW
RobW

Reputation: 10601

Just fixed this today actually. Use the emitCompileError option in version 1.3.0.

Note we can't log specific errors because:

  • Sass doesn't output them as errors, just as stderr and stdout depending on whether you're compiling a single file or a directory
  • node.js stderr and stdout message lines are not guaranteed to be made available in the group they were originally emitted in, so we can't parse the output reliably. https://github.com/sass/sass/issues/1715#issuecomment-98213569

I may do some behind the scenes line-by-line parsing to fix this in the future.

For more info see the gulp-ruby-sass readme and the issue https://github.com/sindresorhus/gulp-ruby-sass/issues/209.

Upvotes: 1

Related Questions