Throw error rather than exit for invalid binaries #2931

This commit is contained in:
Lovell Fuller 2021-10-17 15:14:40 +01:00
parent b9f211fe34
commit 648a1e05da
2 changed files with 5 additions and 3 deletions

View File

@ -18,6 +18,9 @@ Requires libvips v8.11.3
[#2918](https://github.com/lovell/sharp/pull/2918) [#2918](https://github.com/lovell/sharp/pull/2918)
[@dkrnl](https://github.com/dkrnl) [@dkrnl](https://github.com/dkrnl)
* Throw error rather than exit when invalid binaries detected.
[#2931](https://github.com/lovell/sharp/issues/2931)
### v0.29.1 - 7th September 2021 ### v0.29.1 - 7th September 2021
* Add `lightness` option to `modulate` operation. * Add `lightness` option to `modulate` operation.

View File

@ -24,9 +24,8 @@ try {
const loadedModule = Object.keys(require.cache).find((i) => /[\\/]build[\\/]Release[\\/]sharp(.*)\.node$/.test(i)); const loadedModule = Object.keys(require.cache).find((i) => /[\\/]build[\\/]Release[\\/]sharp(.*)\.node$/.test(i));
if (loadedModule) { if (loadedModule) {
const [, loadedPackage] = loadedModule.match(/node_modules[\\/]([^\\/]+)[\\/]/); const [, loadedPackage] = loadedModule.match(/node_modules[\\/]([^\\/]+)[\\/]/);
help.push(`- Ensure version aligns with: "npm ls sharp". Now sharp already loaded in: "${loadedPackage}"`); help.push(`- Ensure the version of sharp aligns with the ${loadedPackage} package: "npm ls sharp"`);
} }
} }
console.error(help.join('\n')); throw new Error(help.join('\n'));
process.exit(1);
} }