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

@@ -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'));
}