Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: return only boolean when useGlobalLibvips is used by gyp #4111

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions lib/libvips.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,21 +162,23 @@ const pkgConfigPath = () => {
}
};

const skipSearch = (status, reason) => {
log(`Detected ${reason}, skipping search for globally-installed libvips`);
const skipSearch = (status, reason, quiet) => {
if (!quiet) {
log(`Detected ${reason}, skipping search for globally-installed libvips`);
}
return status;
};

const useGlobalLibvips = () => {
const useGlobalLibvips = (quiet = false) => {
if (Boolean(process.env.SHARP_IGNORE_GLOBAL_LIBVIPS) === true) {
return skipSearch(false, 'SHARP_IGNORE_GLOBAL_LIBVIPS');
return skipSearch(false, 'SHARP_IGNORE_GLOBAL_LIBVIPS', quiet);
}
if (Boolean(process.env.SHARP_FORCE_GLOBAL_LIBVIPS) === true) {
return skipSearch(true, 'SHARP_FORCE_GLOBAL_LIBVIPS');
return skipSearch(true, 'SHARP_FORCE_GLOBAL_LIBVIPS', quiet);
}
/* istanbul ignore next */
if (isRosetta()) {
return skipSearch(false, 'Rosetta');
return skipSearch(false, 'Rosetta', quiet);
}
const globalVipsVersion = globalLibvipsVersion();
return !!globalVipsVersion && /* istanbul ignore next */
Expand Down
2 changes: 1 addition & 1 deletion src/binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
'conditions': [
['OS != "win"', {
'pkg_config_path': '<!(node -p "require(\'../lib/libvips\').pkgConfigPath()")',
'use_global_libvips': '<!(node -p "Boolean(require(\'../lib/libvips\').useGlobalLibvips()).toString()")'
'use_global_libvips': '<!(node -p "Boolean(require(\'../lib/libvips\').useGlobalLibvips(true)).toString()")'
}, {
'pkg_config_path': '',
'use_global_libvips': ''
Expand Down
3 changes: 3 additions & 0 deletions test/unit/libvips.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ describe('libvips binaries', function () {
const useGlobalLibvips = libvips.useGlobalLibvips();
assert.strictEqual(true, useGlobalLibvips);

const useGlobalLibvipsQuiet = libvips.useGlobalLibvips(true);
assert.strictEqual(true, useGlobalLibvipsQuiet);

delete process.env.SHARP_FORCE_GLOBAL_LIBVIPS;
});
});
Expand Down