mirror of
https://github.com/lovell/sharp.git
synced 2025-07-13 20:30:14 +02:00
Improve/increase installation error handling
This commit is contained in:
parent
c3274e480b
commit
6007e13a22
@ -18,6 +18,12 @@ const platform = require('../lib/platform');
|
||||
const minimumLibvipsVersion = libvips.minimumLibvipsVersion;
|
||||
const distBaseUrl = process.env.SHARP_DIST_BASE_URL || `https://github.com/lovell/sharp-libvips/releases/download/v${minimumLibvipsVersion}/`;
|
||||
|
||||
const fail = function (err) {
|
||||
npmLog.error('sharp', err.message);
|
||||
npmLog.error('sharp', 'Please see http://sharp.pixelplumbing.com/page/install');
|
||||
process.exit(1);
|
||||
};
|
||||
|
||||
const extractTarball = function (tarPath) {
|
||||
const vendorPath = path.join(__dirname, '..', 'vendor');
|
||||
libvips.mkdirSync(vendorPath);
|
||||
@ -27,9 +33,7 @@ const extractTarball = function (tarPath) {
|
||||
cwd: vendorPath,
|
||||
strict: true
|
||||
})
|
||||
.catch(function (err) {
|
||||
throw err;
|
||||
});
|
||||
.catch(fail);
|
||||
};
|
||||
|
||||
try {
|
||||
@ -77,7 +81,9 @@ try {
|
||||
}
|
||||
response.pipe(tmpFile);
|
||||
});
|
||||
tmpFile.on('close', function () {
|
||||
tmpFile
|
||||
.on('error', fail)
|
||||
.on('close', function () {
|
||||
try {
|
||||
// Attempt to rename
|
||||
fs.renameSync(tarPathTemp, tarPathCache);
|
||||
@ -91,7 +97,5 @@ try {
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
npmLog.error('sharp', err.message);
|
||||
npmLog.error('sharp', 'Please see http://sharp.pixelplumbing.com/page/install');
|
||||
process.exit(1);
|
||||
fail(err);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user