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'
|
||||
];
|
||||
|
||||
let sharp;
|
||||
const errors = [];
|
||||
for (const path of paths) {
|
||||
try {
|
||||
module.exports = require(path);
|
||||
sharp = require(path);
|
||||
break;
|
||||
} catch (err) {
|
||||
/* istanbul ignore next */
|
||||
@ -29,7 +30,9 @@ for (const path of paths) {
|
||||
}
|
||||
|
||||
/* 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 help = [`Could not load the "sharp" module using the ${runtimePlatform} runtime`];
|
||||
|
Loading…
x
Reference in New Issue
Block a user