rizalp / gulp-sharp

Gulp plugin to resize image using sharp (libvips binding for nodejs)
MIT License
30 stars 20 forks source link

Seems to be broken out of the box #7

Closed philipwalton closed 8 years ago

philipwalton commented 8 years ago

I just installed this plugin and tried to run it with the exact configuration options specified in the README, and I get an error:

Here's the stack trace:

TypeError: undefined is not a function
    at createSharpPipeline (/Users/philipwalton/Projects/philipwalton/blog/node_modules/gulp-sharp/index.js:53:128)
    at gulpSharp (/Users/philipwalton/Projects/philipwalton/blog/node_modules/gulp-sharp/index.js:124:18)
    at Gulp.<anonymous> (/Users/philipwalton/Projects/philipwalton/blog/gulpfile.babel.js:286:13)
    at module.exports (/Users/philipwalton/Projects/philipwalton/blog/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/Users/philipwalton/Projects/philipwalton/blog/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/Users/philipwalton/Projects/philipwalton/blog/node_modules/orchestrator/index.js:214:10)
    at Gulp.Orchestrator.start (/Users/philipwalton/Projects/philipwalton/blog/node_modules/orchestrator/index.js:134:8)
    at /Users/philipwalton/Projects/philipwalton/blog/node_modules/gulp/bin/gulp.js:129:20
    at doNTCallback0 (node.js:430:9)
    at process._tickCallback (node.js:359:13)
    at Function.Module.runMain (module.js:459:11)
    at startup (node.js:138:18)
    at node.js:974:3

If I replace undefined at index.js:53:128 with function() {}, everything seems to work fine.

I'm using the latest version of gulp, node, and gulp-sharp on Mac OS X

rizalp commented 8 years ago

Hi @philipwalton can you provide me with sample code that throws an exception? I'll try to find out asap

philipwalton commented 8 years ago

Like I said, I used the exact code form the README:

mkdir sharp-test && cd sharp-test
npm install gulp gulp-sharp
touch gulpfile.js

Inside gulpfile.js the only thing I changed from the README was the source file:

var gulp = require('gulp');
var gulpSharp = require('gulp-sharp');

gulp.task('image-resize', function(){

  return gulp.src( './test.png' )
    .pipe(gulpSharp({
      resize : [1280, 800],
      max : true,
      quality : 60,
      progressive : true
    }))
    .pipe(gulp.dest('output'));

});

Then I ran

gulp image-resize

And got the error. Did you try it with a fresh install?

katspaugh commented 8 years ago

Don't you need a comma in the end of line 53 (https://github.com/rizalp/gulp-sharp/blob/master/index.js#L53)?

philipwalton commented 8 years ago

Yeah, because as it is now, the code gets interpreted like this:

undefined(opts.sharpen)
rowanoulton commented 8 years ago

+1

ruslanxdev commented 8 years ago

+1

ruslanxdev commented 8 years ago

Please update here: https://www.npmjs.com/package/gulp-sharp.