cheshire137 / gulp-ruby-haml

Haml plugin for Gulp that uses the Ruby Haml gem.
https://www.npmjs.com/package/gulp-ruby-haml
MIT License
27 stars 13 forks source link

When missing haml gem, error output is not helpful #21

Closed xtoddx closed 8 years ago

xtoddx commented 8 years ago

A snippet of my logs:

app_1      | 19:08:15 gulp.1 | [19:08:15] Starting 'haml-watch'...
app_1      | 19:08:28 gulp.1 | [19:08:28] index.haml was changed
app_1      | 19:08:28 gulp.1 | spawn ENOENT
app_1      | 19:08:28 gulp.1 | execvp(): No such file or directory
app_1      | 19:08:28 gulp.1 |
app_1      | 19:08:28 gulp.1 | no writecb in Transform class

I can see the executing something failed, but it doesn't tell me it was the binary named haml, or that I can install it via rubygems.

I know it is documented in the README, but in my gulp-ruby-haml was a devDependency in the package.json of another project. I think that use-case is worth supporting a little bit better. You can't control if downstream authors have decent READMEs (or complete Dockerfiles, playbooks, etc).

I think it might be nice to rescue the exception currently thrown and re-throw a nicer message like "Unable to find the haml executable on your system $PATH. Visit https://github.com/chesire137/gulp-ruby-haml/wiki/Installing-haml for installation instructions."

cheshire137 commented 8 years ago

Haha thought you were some random with a good suggestion, then looked closer at your avatar. :) Sounds good! Can do.

Can you share which other project had gulp-ruby-haml as a dependency?

xtoddx commented 8 years ago

Its an internal project. I'll paste a similar package.json here ;)

{
  "name": "chickens",
  "license": "UNLICENSED",
  "private": true,
  "devDependencies": {
    "grunt": "~0.4.1",
    "grunt-contrib-connect": "~0.11.2",
    "gulp": "~3.5.2",
    "gulp-util": "~2.2.14",
    "gulp-concat": "~2.1.7",
    "gulp-rename": "~1.0.0",
    "gulp-jshint": "~1.4.0",
    "gulp-uglify": "~0.2.1",
    "gulp-coffee": "~1.4.1",
    "gulp-watch": "~0.5.0",
    "gulp-less": "~1.2.1",
    "gulp-minify-css": "~0.3.0",
    "gulp-clean": "~0.2.4",
    "gulp-ruby-haml": "0.0.7",
    "load-grunt-tasks": "^3.4.0"
  },
  "scripts": {
    "start": "gulp"
  }
}

The gulpfile is a bit too long to include here, but some relevant snippets are:

var haml = require('gulp-ruby-haml');

var on_error = function (err) { console.error(err.message); };

// Compile Haml into HTML
gulp.task('haml', function() {
  return gulp.src('./app/assets/haml/**/*.haml', {read: false}).
              pipe(haml().on('error', on_error)).
              pipe(gulp.dest('./public'));
});

// Watch for changes in Haml files
gulp.task('haml-watch', function() {
  return gulp.src('./app/assets/haml/**/*.haml', {read: false}).
              pipe(watch()).
              pipe(haml().on('error', on_error)).
              pipe(gulp.dest('./public'));
});
cheshire137 commented 8 years ago

Fixed in version 0.0.9.