@mole-inc/imagemin-webp
Advanced tools
Comparing version 6.0.1 to 7.0.0
25
index.js
'use strict'; | ||
const {cwebpBin} = require('@mole-inc/cwebp-bin'); | ||
const execBuffer = require('exec-buffer'); | ||
const isCwebpReadable = require('is-cwebp-readable'); | ||
const cwebp = require('@mole-inc/cwebp-bin'); | ||
module.exports = (options = {}) => input => { | ||
module.exports = (options = {}) => async input => { | ||
if (!Buffer.isBuffer(input)) { | ||
return Promise.reject(new TypeError(`Expected \`input\` to be of type \`Buffer\` but received type \`${typeof input}\``)); | ||
throw new TypeError(`Expected \`input\` to be of type \`Buffer\` but received type \`${typeof input}\``); | ||
} | ||
if (!isCwebpReadable(input)) { | ||
return Promise.resolve(input); | ||
return input; | ||
} | ||
@@ -17,3 +17,3 @@ | ||
'-quiet', | ||
'-mt' | ||
'-mt', | ||
]; | ||
@@ -79,10 +79,13 @@ | ||
return execBuffer({ | ||
args, | ||
bin: cwebp, | ||
input | ||
}).catch(error => { | ||
try { | ||
return execBuffer({ | ||
args, | ||
bin: cwebpBin.path, | ||
input, | ||
}); | ||
} catch (error) { | ||
error.message = error.stderr || error.message; | ||
throw error; | ||
}); | ||
} | ||
}; |
{ | ||
"name": "@mole-inc/imagemin-webp", | ||
"version": "6.0.1", | ||
"version": "7.0.0", | ||
"description": "WebP imagemin plugin", | ||
@@ -10,4 +10,5 @@ "license": "MIT", | ||
}, | ||
"type": "commonjs", | ||
"engines": { | ||
"node": ">=10.13.0" | ||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0" | ||
}, | ||
@@ -17,3 +18,4 @@ "scripts": { | ||
"coverage": "nyc report --reporter=lcov", | ||
"release": "standard-version" | ||
"release": "standard-version", | ||
"prepare": "husky install" | ||
}, | ||
@@ -40,4 +42,4 @@ "publishConfig": { | ||
"dependencies": { | ||
"@mole-inc/cwebp-bin": ">=6.0.0", | ||
"exec-buffer": "^3.0.0", | ||
"@mole-inc/cwebp-bin": "^9.0.2", | ||
"exec-buffer": "^3.2.0", | ||
"is-cwebp-readable": "^3.0.0" | ||
@@ -48,9 +50,17 @@ }, | ||
"@commitlint/config-conventional": "latest", | ||
"ava": "^3.7.1", | ||
"husky": "^4.2.5", | ||
"is-webp": "^1.0.0", | ||
"nyc": "^15.0.1", | ||
"ava": "^3.15.0", | ||
"husky": "^7.0.4", | ||
"is-webp": "^1.0.1", | ||
"nyc": "^15.1.0", | ||
"standard-version": "latest", | ||
"xo": "^0.29.1" | ||
"xo": "^0.43.0" | ||
}, | ||
"xo": { | ||
"rules": { | ||
"unicorn/prefer-node-protocol": "off", | ||
"unicorn/explicit-length-check": "off", | ||
"unicorn/prefer-module": "off", | ||
"node/prefer-global/buffer": "off" | ||
} | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# imagemin-webp ![Node CI](https://github.com/mole-inc/imagemin-webp/workflows/Node%20CI/badge.svg) | ||
# imagemin-webp [![Node CI](https://github.com/mole-inc/imagemin-webp/actions/workflows/nodejs.yml/badge.svg)](https://github.com/mole-inc/imagemin-webp/actions/workflows/nodejs.yml) | ||
@@ -3,0 +3,0 @@ > WebP [imagemin](https://github.com/mole-inc/imagemin) plugin |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6758
69
Updated@mole-inc/cwebp-bin@^9.0.2
Updatedexec-buffer@^3.2.0