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

Expose path information on failure #43

Open
ide opened this issue Jul 16, 2014 · 2 comments
Open

Expose path information on failure #43

ide opened this issue Jul 16, 2014 · 2 comments

Comments

@ide
Copy link

ide commented Jul 16, 2014

I would like to write an error handler that writes a small JS file when gulp-coffee fails. For example if a.coffee has a syntax error, I want to create a.js with:

throw new Error('Error compiling a.coffee: <syntaxerror.stack>');

For this, my gulp task needs access to the name of the JS file that gulp-coffee was trying to create.

@paulyoung
Copy link

This should get you what you need.

gulpfile.coffee

gulp = require 'gulp'
coffee = require 'gulp-coffee'
path = require 'path'

gulp.task 'compile', ->
  coffeeStream = coffee().on 'error', (error) ->
    {filename} = error
    extension = path.extname error.filename
    dirname = path.dirname filename
    basename = path.basename error.filename, '.coffee'
    target = path.join dirname, "#{basename}.js"

  return gulp.src('src/**/*.coffee')
    .pipe(coffeeStream)
    .pipe(gulp.dest('lib'))

@yocontra
Copy link
Member

yocontra commented Aug 4, 2014

I think the problem here came from CS 1.6 -> 1.7

It used to be 'fileName' which is a semi-standard Error class attributed, and it changed to 'filename' which isn't. I'll see what I can do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants