mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 15:25:07 +01:00
Verify platform of vendor binaries at install and run time
This commit is contained in:
@@ -6,8 +6,24 @@ const stream = require('stream');
|
||||
const events = require('events');
|
||||
const semver = require('semver');
|
||||
const is = require('./is');
|
||||
const platform = require('./platform');
|
||||
const sharp = require('../build/Release/sharp.node');
|
||||
|
||||
// Vendor platform
|
||||
(function () {
|
||||
let vendorPlatformId;
|
||||
try {
|
||||
vendorPlatformId = require('../vendor/platform.json');
|
||||
} catch (err) {
|
||||
return;
|
||||
}
|
||||
const currentPlatformId = platform();
|
||||
/* istanbul ignore if */
|
||||
if (currentPlatformId !== vendorPlatformId) {
|
||||
throw new Error(`'${vendorPlatformId}' binaries cannot be used on the '${currentPlatformId}' platform. Please remove the 'node_modules/sharp/vendor' directory and run 'npm rebuild'.`);
|
||||
}
|
||||
})();
|
||||
|
||||
// Versioning
|
||||
let versions = {
|
||||
vips: sharp.libvipsVersion()
|
||||
@@ -21,7 +37,7 @@ let versions = {
|
||||
}
|
||||
// Include versions of dependencies, if present
|
||||
try {
|
||||
versions = require('../vendor/lib/versions.json');
|
||||
versions = require('../vendor/versions.json');
|
||||
} catch (err) {}
|
||||
})();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user