Ensure presence of libvips before invoking node-gyp

This commit is contained in:
Lovell Fuller 2021-05-16 19:40:43 +01:00
parent 81e388a4cc
commit b69a54fc75
4 changed files with 14 additions and 2 deletions

View File

@ -6,6 +6,8 @@ Requires libvips v8.10.6
### v0.28.3 - TBD ### v0.28.3 - TBD
* Ensure presence of libvips, vendored or global, before invoking node-gyp.
* Skip shrink-on-load for multi-page WebP. * Skip shrink-on-load for multi-page WebP.
[#2714](https://github.com/lovell/sharp/issues/2714) [#2714](https://github.com/lovell/sharp/issues/2714)

11
install/can-compile.js Normal file
View File

@ -0,0 +1,11 @@
'use strict';
const libvips = require('../lib/libvips');
try {
if (!(libvips.useGlobalLibvips() || libvips.hasVendoredLibvips())) {
process.exitCode = 1;
}
} catch (err) {
process.exitCode = 1;
}

View File

@ -43,7 +43,6 @@ const fail = function (err) {
if (err.code === 'EACCES') { if (err.code === 'EACCES') {
libvips.log('Are you trying to install as a root or sudo user? Try again with the --unsafe-perm flag'); libvips.log('Are you trying to install as a root or sudo user? Try again with the --unsafe-perm flag');
} }
libvips.log('Attempting to build from source via node-gyp but this may fail due to the above error');
libvips.log('Please see https://sharp.pixelplumbing.com/install for required dependencies'); libvips.log('Please see https://sharp.pixelplumbing.com/install for required dependencies');
process.exit(1); process.exit(1);
}; };

View File

@ -79,7 +79,7 @@
"Michael Nutt <michael@nutt.im>" "Michael Nutt <michael@nutt.im>"
], ],
"scripts": { "scripts": {
"install": "(node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)", "install": "(node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)",
"clean": "rm -rf node_modules/ build/ vendor/ .nyc_output/ coverage/ test/fixtures/output.*", "clean": "rm -rf node_modules/ build/ vendor/ .nyc_output/ coverage/ test/fixtures/output.*",
"test": "npm run test-lint && npm run test-unit && npm run test-licensing", "test": "npm run test-lint && npm run test-unit && npm run test-licensing",
"test-lint": "semistandard && cpplint", "test-lint": "semistandard && cpplint",