mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 18:40:16 +02:00
Ensure versions prop detects use of global libvips
This commit is contained in:
parent
09460d7af4
commit
7e25dd7be1
@ -1,7 +1,8 @@
|
|||||||
## versions
|
## versions
|
||||||
> versions
|
> versions
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
|
File diff suppressed because one or more lines are too long
@ -10,6 +10,9 @@ const is = require('./is');
|
|||||||
const { runtimePlatformArch } = require('./libvips');
|
const { runtimePlatformArch } = require('./libvips');
|
||||||
const sharp = require('./sharp');
|
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.
|
* An Object containing nested boolean values representing the available input and output formats/methods.
|
||||||
* @member
|
* @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
|
* @member
|
||||||
* @example
|
* @example
|
||||||
* console.log(sharp.versions);
|
* console.log(sharp.versions);
|
||||||
*/
|
*/
|
||||||
let versions = {
|
let versions = {
|
||||||
vips: sharp.libvipsVersion()
|
vips: libvipsVersion.semver
|
||||||
};
|
};
|
||||||
try {
|
/* istanbul ignore next */
|
||||||
versions = require(`@sharpen/sharp-${runtimePlatformArch()}/versions`);
|
if (!libvipsVersion.isGlobal) {
|
||||||
} catch (_) {
|
|
||||||
try {
|
try {
|
||||||
versions = require(`@sharpen/sharp-libvips-${runtimePlatformArch()}/versions`);
|
versions = require(`@sharpen/sharp-${runtimePlatform}/versions`);
|
||||||
} catch (_) {}
|
} catch (_) {
|
||||||
|
try {
|
||||||
|
versions = require(`@sharpen/sharp-libvips-${runtimePlatform}/versions`);
|
||||||
|
} catch (_) {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
versions.sharp = require('../package.json').version;
|
versions.sharp = require('../package.json').version;
|
||||||
|
|
||||||
|
@ -111,6 +111,9 @@
|
|||||||
# Use pkg-config for include and lib
|
# Use pkg-config for include and lib
|
||||||
'include_dirs': ['<!@(PKG_CONFIG_PATH="<(pkg_config_path)" pkg-config --cflags-only-I vips-cpp vips glib-2.0 | sed s\/-I//g)'],
|
'include_dirs': ['<!@(PKG_CONFIG_PATH="<(pkg_config_path)" pkg-config --cflags-only-I vips-cpp vips glib-2.0 | sed s\/-I//g)'],
|
||||||
'libraries': ['<!@(PKG_CONFIG_PATH="<(pkg_config_path)" pkg-config --libs vips-cpp)'],
|
'libraries': ['<!@(PKG_CONFIG_PATH="<(pkg_config_path)" pkg-config --libs vips-cpp)'],
|
||||||
|
'defines': [
|
||||||
|
'SHARP_USE_GLOBAL_LIBVIPS'
|
||||||
|
],
|
||||||
'conditions': [
|
'conditions': [
|
||||||
['OS == "linux"', {
|
['OS == "linux"', {
|
||||||
'defines': [
|
'defines': [
|
||||||
|
@ -92,9 +92,18 @@ Napi::Value simd(const Napi::CallbackInfo& info) {
|
|||||||
Get libvips version
|
Get libvips version
|
||||||
*/
|
*/
|
||||||
Napi::Value libvipsVersion(const Napi::CallbackInfo& info) {
|
Napi::Value libvipsVersion(const Napi::CallbackInfo& info) {
|
||||||
char version[9];
|
Napi::Env env = info.Env();
|
||||||
std::snprintf(version, sizeof(version), "%d.%d.%d", vips_version(0), vips_version(1), vips_version(2));
|
Napi::Object version = Napi::Object::New(env);
|
||||||
return Napi::String::New(info.Env(), version);
|
|
||||||
|
char semver[9];
|
||||||
|
std::snprintf(semver, sizeof(semver), "%d.%d.%d", vips_version(0), vips_version(1), vips_version(2));
|
||||||
|
version.Set("semver", Napi::String::New(env, semver));
|
||||||
|
#ifdef SHARP_USE_GLOBAL_LIBVIPS
|
||||||
|
version.Set("isGlobal", Napi::Boolean::New(env, true));
|
||||||
|
#else
|
||||||
|
version.Set("isGlobal", Napi::Boolean::New(env, false));
|
||||||
|
#endif
|
||||||
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user