Skip to content

Commit

Permalink
Throw error rather than exit for invalid binaries #2931
Browse files Browse the repository at this point in the history
  • Loading branch information
lovell committed Oct 17, 2021
1 parent b9f211f commit 648a1e0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 3 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 2 additions & 3 deletions lib/sharp.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}

0 comments on commit 648a1e0

Please sign in to comment.