mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 10:30:15 +02:00
Ensure SHARP_FORCE_GLOBAL_LIBVIPS option works correctly #4111
Allows the install/check script to inject a logger function, keeping its use within binding.gyp free of additional output. Co-authored-by: Lovell Fuller <github@lovell.info>
This commit is contained in:
parent
cc96c21e42
commit
56fae3eda1
@ -4,6 +4,12 @@
|
|||||||
|
|
||||||
Requires libvips v8.15.2
|
Requires libvips v8.15.2
|
||||||
|
|
||||||
|
### v0.33.5 - TBD
|
||||||
|
|
||||||
|
* Ensure option to force use of a globally-installed libvips works correctly.
|
||||||
|
[#4111](https://github.com/lovell/sharp/pull/4111)
|
||||||
|
[@project0](https://github.com/project0)
|
||||||
|
|
||||||
### v0.33.4 - 16th May 2024
|
### v0.33.4 - 16th May 2024
|
||||||
|
|
||||||
* Remove experimental status from `pipelineColourspace`.
|
* Remove experimental status from `pipelineColourspace`.
|
||||||
|
@ -293,3 +293,6 @@ GitHub: https://github.com/mertalev
|
|||||||
|
|
||||||
Name: Adriaan Meuris
|
Name: Adriaan Meuris
|
||||||
GitHub: https://github.com/adriaanmeuris
|
GitHub: https://github.com/adriaanmeuris
|
||||||
|
|
||||||
|
Name: Richard Hillmann
|
||||||
|
GitHub: https://github.com/project0
|
||||||
|
@ -30,7 +30,7 @@ try {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (useGlobalLibvips()) {
|
if (useGlobalLibvips(log)) {
|
||||||
buildFromSource(`Detected globally-installed libvips v${globalLibvipsVersion()}`);
|
buildFromSource(`Detected globally-installed libvips v${globalLibvipsVersion()}`);
|
||||||
} else if (process.env.npm_config_build_from_source) {
|
} else if (process.env.npm_config_build_from_source) {
|
||||||
buildFromSource('Detected --build-from-source flag');
|
buildFromSource('Detected --build-from-source flag');
|
||||||
|
@ -162,21 +162,23 @@ const pkgConfigPath = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const skipSearch = (status, reason) => {
|
const skipSearch = (status, reason, logger) => {
|
||||||
log(`Detected ${reason}, skipping search for globally-installed libvips`);
|
if (logger) {
|
||||||
|
logger(`Detected ${reason}, skipping search for globally-installed libvips`);
|
||||||
|
}
|
||||||
return status;
|
return status;
|
||||||
};
|
};
|
||||||
|
|
||||||
const useGlobalLibvips = () => {
|
const useGlobalLibvips = (logger) => {
|
||||||
if (Boolean(process.env.SHARP_IGNORE_GLOBAL_LIBVIPS) === true) {
|
if (Boolean(process.env.SHARP_IGNORE_GLOBAL_LIBVIPS) === true) {
|
||||||
return skipSearch(false, 'SHARP_IGNORE_GLOBAL_LIBVIPS');
|
return skipSearch(false, 'SHARP_IGNORE_GLOBAL_LIBVIPS', logger);
|
||||||
}
|
}
|
||||||
if (Boolean(process.env.SHARP_FORCE_GLOBAL_LIBVIPS) === true) {
|
if (Boolean(process.env.SHARP_FORCE_GLOBAL_LIBVIPS) === true) {
|
||||||
return skipSearch(true, 'SHARP_FORCE_GLOBAL_LIBVIPS');
|
return skipSearch(true, 'SHARP_FORCE_GLOBAL_LIBVIPS', logger);
|
||||||
}
|
}
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
if (isRosetta()) {
|
if (isRosetta()) {
|
||||||
return skipSearch(false, 'Rosetta');
|
return skipSearch(false, 'Rosetta', logger);
|
||||||
}
|
}
|
||||||
const globalVipsVersion = globalLibvipsVersion();
|
const globalVipsVersion = globalLibvipsVersion();
|
||||||
return !!globalVipsVersion && /* istanbul ignore next */
|
return !!globalVipsVersion && /* istanbul ignore next */
|
||||||
|
@ -72,6 +72,15 @@ describe('libvips binaries', function () {
|
|||||||
const useGlobalLibvips = libvips.useGlobalLibvips();
|
const useGlobalLibvips = libvips.useGlobalLibvips();
|
||||||
assert.strictEqual(true, useGlobalLibvips);
|
assert.strictEqual(true, useGlobalLibvips);
|
||||||
|
|
||||||
|
let logged = false;
|
||||||
|
const logger = function (message) {
|
||||||
|
assert.strictEqual(message, 'Detected SHARP_FORCE_GLOBAL_LIBVIPS, skipping search for globally-installed libvips');
|
||||||
|
logged = true;
|
||||||
|
};
|
||||||
|
const useGlobalLibvipsWithLogger = libvips.useGlobalLibvips(logger);
|
||||||
|
assert.strictEqual(true, useGlobalLibvipsWithLogger);
|
||||||
|
assert.strictEqual(true, logged);
|
||||||
|
|
||||||
delete process.env.SHARP_FORCE_GLOBAL_LIBVIPS;
|
delete process.env.SHARP_FORCE_GLOBAL_LIBVIPS;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user