From 648a1e05da2f7b5777184dc25ac16473e2486cce Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Sun, 17 Oct 2021 15:14:40 +0100 Subject: [PATCH] Throw error rather than exit for invalid binaries #2931 --- docs/changelog.md | 3 +++ lib/sharp.js | 5 ++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 29d5f2802..7c38cd04d 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -18,6 +18,9 @@ Requires libvips v8.11.3 [#2918](https://github.com/lovell/sharp/pull/2918) [@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 * Add `lightness` option to `modulate` operation. diff --git a/lib/sharp.js b/lib/sharp.js index 7d0b72ed9..3fd037855 100644 --- a/lib/sharp.js +++ b/lib/sharp.js @@ -24,9 +24,8 @@ try { const loadedModule = Object.keys(require.cache).find((i) => /[\\/]build[\\/]Release[\\/]sharp(.*)\.node$/.test(i)); if (loadedModule) { 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')); - process.exit(1); + throw new Error(help.join('\n')); }