Skip to content

Commit

Permalink
Use buffer directly (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shogo Sensui authored and shinnn committed Jul 17, 2016
1 parent e82da89 commit 465b237
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
13 changes: 5 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
const execBuffer = require('exec-buffer');
const execa = require('execa');
const isJpg = require('is-jpg');
const mozjpeg = require('mozjpeg');

Expand All @@ -14,7 +14,7 @@ module.exports = opts => buf => {
return Promise.resolve(buf);
}

const args = ['-outfile', execBuffer.output];
const args = [];

if (typeof opts.quality !== 'undefined') {
args.push('-quality', opts.quality);
Expand Down Expand Up @@ -76,12 +76,9 @@ module.exports = opts => buf => {
args.push('-maxmemory', opts.maxmemory);
}

args.push(execBuffer.input);

return execBuffer({
input: buf,
bin: mozjpeg,
args
return execa.stdout(mozjpeg, args, {
encoding: null,
input: buf
}).catch(err => {
err.message = err.stderr || err.message;
throw err;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"optimize"
],
"dependencies": {
"exec-buffer": "^3.0.0",
"execa": "^0.4.0",
"is-jpg": "^1.0.0",
"mozjpeg": "^4.0.0"
},
Expand Down

0 comments on commit 465b237

Please sign in to comment.