mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 10:30:15 +02:00
Correctly check for when sharp is unavailable (#3848)
This commit is contained in:
parent
2dba5b5451
commit
75ef61a958
@ -17,10 +17,11 @@ const paths = [
|
|||||||
'@img/sharp-wasm32/sharp.node'
|
'@img/sharp-wasm32/sharp.node'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
let sharp;
|
||||||
const errors = [];
|
const errors = [];
|
||||||
for (const path of paths) {
|
for (const path of paths) {
|
||||||
try {
|
try {
|
||||||
module.exports = require(path);
|
sharp = require(path);
|
||||||
break;
|
break;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
@ -29,7 +30,9 @@ for (const path of paths) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
if (!module.exports) {
|
if (sharp) {
|
||||||
|
module.exports = sharp;
|
||||||
|
} else {
|
||||||
const [isLinux, isMacOs, isWindows] = ['linux', 'darwin', 'win32'].map(os => runtimePlatform.startsWith(os));
|
const [isLinux, isMacOs, isWindows] = ['linux', 'darwin', 'win32'].map(os => runtimePlatform.startsWith(os));
|
||||||
|
|
||||||
const help = [`Could not load the "sharp" module using the ${runtimePlatform} runtime`];
|
const help = [`Could not load the "sharp" module using the ${runtimePlatform} runtime`];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user