Well, I'm trying to execute an inkscape task for every file in a gulp task.
The idea is to transform every SVG file I have in a compound path (an SVG composed only by one complex path).
I'm trying to achieve this with something like this:
gulp.task('minify-shapes', function() { function makeChange() { var Stream = require('stream'); function transform(file, cb) { var svgConverter = new Inkscape(['--verb=ObjectToPath', '--export-plain-svg']); var stdout = new Stream(); var bufs = []; console.log(file.history); stdout.on('data', function(d) { bufs.push(d); }); stdout.on('end', function() { var buf = Buffer.concat(bufs); file.contents = buf; cb(null, file); }); file.pipe(svgConverter).pipe(stdout); } return require('event-stream').map(transform); } return gulp.src('app/assets/shapes/**/*.svg') .pipe(makeChange()) .pipe(gulp.dest('app/assets/shapes')); }); The problem is, this npm package Inkscape works with streams, so I should somehow pipe Inkscape output and write back to gulp file.contents.
This seems to not work because the conversion of this Inkscape stream output to a buffer is async, so it's not work in sync with gulp task flow.
The error I'm receiving is:
stream.js:59 dest.end(); ^ TypeError: dest.end is not a function at Inkscape.onend (stream.js:59:10) at emitNone (events.js:91:20) at Inkscape.emit (events.js:185:7) at Inkscape.<anonymous> (node_modules\inkscape\lib\Inkscape.js:161:26) at emitNone (events.js:91:20) at ReadStream.emit (events.js:185:7) at endReadableNT (_stream_readable.js:926:12) at _combinedTickCallback (internal/process/next_tick.js:74:11) at process._tickCallback (internal/process/next_tick.js:98:9) Can somebody help me?