Ensure vendor platform mismatch throws error #1303

This commit is contained in:
Lovell Fuller
2018-08-04 21:34:11 +01:00
parent 2de062a34a
commit 75556bb57c
2 changed files with 8 additions and 2 deletions

View File

@@ -23,14 +23,17 @@ const globalLibvipsVersion = function () {
const hasVendoredLibvips = function () {
const currentPlatformId = platform();
let vendorPlatformId;
try {
const vendorPlatformId = require(path.join(__dirname, '..', 'vendor', 'platform.json'));
vendorPlatformId = require(path.join(__dirname, '..', 'vendor', 'platform.json'));
} catch (err) {}
if (vendorPlatformId) {
if (currentPlatformId === vendorPlatformId) {
return true;
} else {
throw new Error(`'${vendorPlatformId}' binaries cannot be used on the '${currentPlatformId}' platform. Please remove the 'node_modules/sharp/vendor' directory and run 'npm install'.`);
}
} catch (err) {}
}
return false;
};