mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 15:25:07 +01:00
Ensure versions prop detects use of global libvips
This commit is contained in:
@@ -10,6 +10,9 @@ const is = require('./is');
|
||||
const { runtimePlatformArch } = require('./libvips');
|
||||
const sharp = require('./sharp');
|
||||
|
||||
const runtimePlatform = runtimePlatformArch();
|
||||
const libvipsVersion = sharp.libvipsVersion();
|
||||
|
||||
/**
|
||||
* An Object containing nested boolean values representing the available input and output formats/methods.
|
||||
* @member
|
||||
@@ -44,20 +47,25 @@ const interpolators = {
|
||||
};
|
||||
|
||||
/**
|
||||
* An Object containing the version numbers of sharp, libvips and its dependencies.
|
||||
* An Object containing the version numbers of sharp, libvips
|
||||
* and (when using prebuilt binaries) its dependencies.
|
||||
*
|
||||
* @member
|
||||
* @example
|
||||
* console.log(sharp.versions);
|
||||
*/
|
||||
let versions = {
|
||||
vips: sharp.libvipsVersion()
|
||||
vips: libvipsVersion.semver
|
||||
};
|
||||
try {
|
||||
versions = require(`@sharpen/sharp-${runtimePlatformArch()}/versions`);
|
||||
} catch (_) {
|
||||
/* istanbul ignore next */
|
||||
if (!libvipsVersion.isGlobal) {
|
||||
try {
|
||||
versions = require(`@sharpen/sharp-libvips-${runtimePlatformArch()}/versions`);
|
||||
} catch (_) {}
|
||||
versions = require(`@sharpen/sharp-${runtimePlatform}/versions`);
|
||||
} catch (_) {
|
||||
try {
|
||||
versions = require(`@sharpen/sharp-libvips-${runtimePlatform}/versions`);
|
||||
} catch (_) {}
|
||||
}
|
||||
}
|
||||
versions.sharp = require('../package.json').version;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user