GithubHelp home page GithubHelp logo

Comments (8)

yocontra avatar yocontra commented on August 16, 2024

How does .on('error', console.error)) look?

from gulp-coffee.

rhys-vdw avatar rhys-vdw commented on August 16, 2024

Same output with console.error.

Okay, so this prints correctly:

I told a lie, they were all broken. At some stage while I was playing with different permutations I though I had it working with the following code, but no longer. I'm not even sure this is a gulp-coffee problem now, as it's working fine in my backend project.

gulp.task('scripts', function (done) {
  return gulp.src(appSrc.scripts)
    .pipe(coffee())
    .on('error', util.log)
    .pipe(gulp.dest(compileDest.scripts))
    .pipe(size())
    ;
});

And both of these print output as above:

gulp.task('scripts', function (done) {
  return gulp.src(appSrc.scripts)
    .pipe(coffee())
    .on('error', util.log)
    .pipe(gulp.dest(compileDest.scripts))
    .pipe(size())
    ;
});
gulp.task('scripts', function (done) {
  return gulp.src(appSrc.scripts)
    .pipe(coffee().on('error', util.log))
    .pipe(gulp.dest(compileDest.scripts))
    .pipe(size())
    ;
});

from gulp-coffee.

yocontra avatar yocontra commented on August 16, 2024

Different versions of gulp-util? Are you sure everything is up to date with the latest?

from gulp-coffee.

edmundito avatar edmundito commented on August 16, 2024

I peeked into gulp-util (3.0.6) myself and found that for whatever reason, the error is not being formatted toString(). This is is how I worked around it in my gulpfile:

$ = require('gulp-load-plugins')()
errorHandler = (error) -> $.util.log error.toString()

# Inside the task...
.pipe($.coffee(bare: true).on('error', errorHandler))

from gulp-coffee.

yocontra avatar yocontra commented on August 16, 2024

@edmundito Something that needs to be fixed in gulp-util? What were your findings?

from gulp-coffee.

edmundito avatar edmundito commented on August 16, 2024

Yes, this is mainly related to the implementation of the log() function in gulp-util 3.0.6. I've noticed that master is currently a bit different, however what I found is that it has to do with the behavior of console.log in Node (as well as Chrome and Safari). console.log seems to not respect the toString declaration when outputting objects by themselves:

$ node
> function Cls() {}; Cls.prototype.toString = function () { return 'the string'; }
[Function]
> var c = new Cls()
undefined
> console.log(c)
Cls {}
undefined
> console.log(c.toString())
the string
undefined
> console.log('' + c)
the string
undefined
> console.log.apply(console, [c, c, c])
Cls {} Cls {} Cls {}

This could also be the cause behind the result in gulpjs/gulp-util#74.

from gulp-coffee.

yocontra avatar yocontra commented on August 16, 2024

The PluginError class is a disaster in gulp-util right now - there are plans to replace it with something simpler called BetterError but I haven't had time to dedicate to it.

With that - I'd take a PR to fix this issue in gulp-util if any of you have time.

from gulp-coffee.

yocontra avatar yocontra commented on August 16, 2024

Closing, this was split out of gulp-util into the plugin-error module and we use that now. Any fixes for formatting should go there.

from gulp-coffee.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.