Skip to content

Commit

Permalink
Remove duplicate libvips version/platform check
Browse files Browse the repository at this point in the history
  • Loading branch information
lovell committed Sep 21, 2018
1 parent 1106aac commit 71755b6
Showing 1 changed file with 8 additions and 35 deletions.
43 changes: 8 additions & 35 deletions lib/constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,10 @@ const path = require('path');
const util = require('util');
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()
};
(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) {}
})();
require('./libvips').hasVendoredLibvips();
const sharp = require('../build/Release/sharp.node');

// Use NODE_DEBUG=sharp to enable libvips warnings
const debuglog = util.debuglog('sharp');
Expand Down Expand Up @@ -251,7 +219,12 @@ Sharp.format = sharp.format();
* @example
* console.log(sharp.versions);
*/
Sharp.versions = versions;
Sharp.versions = {
vips: sharp.libvipsVersion()
};
try {
Sharp.versions = require('../vendor/versions.json');
} catch (err) {}

/**
* Export constructor.
Expand Down

0 comments on commit 71755b6

Please sign in to comment.