mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 10:30:15 +02:00
Remove duplicate libvips version/platform check
This commit is contained in:
parent
1106aac2d8
commit
71755b69e4
@ -4,43 +4,11 @@ const path = require('path');
|
|||||||
const util = require('util');
|
const util = require('util');
|
||||||
const stream = require('stream');
|
const stream = require('stream');
|
||||||
const events = require('events');
|
const events = require('events');
|
||||||
const semver = require('semver');
|
|
||||||
const is = require('./is');
|
const is = require('./is');
|
||||||
const platform = require('./platform');
|
|
||||||
|
require('./libvips').hasVendoredLibvips();
|
||||||
const sharp = require('../build/Release/sharp.node');
|
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()
|
|
||||||
};
|
|
||||||
(function () {
|
|
||||||
// Does libvips meet minimum requirement?
|
|
||||||
const libvipsVersionMin = require('../package.json').config.libvips;
|
|
||||||
/* istanbul ignore if */
|
|
||||||
if (semver.lt(versions.vips, libvipsVersionMin)) {
|
|
||||||
throw new Error('Found libvips ' + versions.vips + ' but require at least ' + libvipsVersionMin);
|
|
||||||
}
|
|
||||||
// Include versions of dependencies, if present
|
|
||||||
try {
|
|
||||||
versions = require('../vendor/versions.json');
|
|
||||||
} catch (err) {}
|
|
||||||
})();
|
|
||||||
|
|
||||||
// Use NODE_DEBUG=sharp to enable libvips warnings
|
// Use NODE_DEBUG=sharp to enable libvips warnings
|
||||||
const debuglog = util.debuglog('sharp');
|
const debuglog = util.debuglog('sharp');
|
||||||
|
|
||||||
@ -251,7 +219,12 @@ Sharp.format = sharp.format();
|
|||||||
* @example
|
* @example
|
||||||
* console.log(sharp.versions);
|
* console.log(sharp.versions);
|
||||||
*/
|
*/
|
||||||
Sharp.versions = versions;
|
Sharp.versions = {
|
||||||
|
vips: sharp.libvipsVersion()
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
Sharp.versions = require('../vendor/versions.json');
|
||||||
|
} catch (err) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Export constructor.
|
* Export constructor.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user