allbitsnbytes / gulp-imageoptim

Gulp plugin to optimize images using ImageOptim
Other
22 stars 2 forks source link

Console clutter when passing no images #11

Open tjgavlick opened 7 years ago

tjgavlick commented 7 years ago

Hi there! Thanks for the extremely useful plugin.

My issue is that when no images are passed through to this plugin (for example, filtering via newer after a delete event), I get a console error:

{ Error: Command failed: bash node_modules/gulp-imageoptim/scripts/optimize.bash 06962c9b44b38b68736f1c7e7d8d2b81 

    at ChildProcess.exithandler (child_process.js:205:12)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:194:7)
    at maybeClose (internal/child_process.js:899:16)
    at Socket.<anonymous> (internal/child_process.js:342:11)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:191:7)
    at Pipe._handle.close [as _onclose] (net.js:511:12)
  killed: false,
  code: 1,
  signal: null,
  cmd: 'bash node_modules/gulp-imageoptim/scripts/optimize.bash 06962c9b44b38b68736f1c7e7d8d2b81 ' }

Gulp does not exit and subsequent watch events execute properly, so functionally, everything is working fine. Just wondering if this error can be accounted for so my users don't get alarmed by scary-looking errors in their consoles. Or, if there's a way I should be handling this error on my side, let me know.

edit: for reference, I am using pump in place of pipe. Here's my imageOptim task:

let out = 'dist/images';
pump(
  [
    gulp.src(imageFiles),
    newer(out),
    imageOptim.optimize(),
    gulp.dest(out)
  ],
  done
);
richjdsmith commented 6 years ago

@tjgavlick Did you ever find a solution to this? I'm running into the issue when passing an already compressed image to it.

tjgavlick commented 6 years ago

@richjdsmith I'm afraid I never did, no. Ended up just living with it, since the functionality is still intact, at least. But I've been meaning to check around for alternative optimization solutions.