mirror of
https://github.com/lovell/sharp.git
synced 2025-12-18 23:05:04 +01:00
Prevent use of linux-x64 binaries with v1 microarchitecture
This commit is contained in:
12
lib/sharp.js
12
lib/sharp.js
@@ -17,9 +17,9 @@ const paths = [
|
||||
'@img/sharp-wasm32/sharp.node'
|
||||
];
|
||||
|
||||
let sharp;
|
||||
let path, sharp;
|
||||
const errors = [];
|
||||
for (const path of paths) {
|
||||
for (path of paths) {
|
||||
try {
|
||||
sharp = require(path);
|
||||
break;
|
||||
@@ -29,6 +29,14 @@ for (const path of paths) {
|
||||
}
|
||||
}
|
||||
|
||||
/* istanbul ignore next */
|
||||
if (sharp && path.startsWith('@img/sharp-linux-x64') && !sharp._isUsingX64V2()) {
|
||||
const err = new Error('Prebuilt binaries for linux-x64 require v2 microarchitecture');
|
||||
err.code = 'Unsupported CPU';
|
||||
errors.push(err);
|
||||
sharp = null;
|
||||
}
|
||||
|
||||
/* istanbul ignore next */
|
||||
if (sharp) {
|
||||
module.exports = sharp;
|
||||
|
||||
Reference in New Issue
Block a user