Install: log errors with more obvious prefix

This commit is contained in:
Lovell Fuller 2021-04-01 16:20:58 +01:00
parent 08a25a0c8f
commit fe0767df13
4 changed files with 10 additions and 4 deletions

View File

@ -4,6 +4,10 @@
Requires libvips v8.10.6 Requires libvips v8.10.6
### v0.28.1 - TBD
* Ensure all installation errors are logged with a more obvious prefix.
### v0.28.0 - 29th March 2021 ### v0.28.0 - 29th March 2021
* Prebuilt binaries now include mozjpeg and libimagequant (BSD 2-Clause). * Prebuilt binaries now include mozjpeg and libimagequant (BSD 2-Clause).

View File

@ -145,7 +145,9 @@ try {
tmpFileStream tmpFileStream
.on('error', function (err) { .on('error', function (err) {
// Clean up temporary file // Clean up temporary file
fs.unlinkSync(tarPathTemp); try {
fs.unlinkSync(tarPathTemp);
} catch (e) {}
fail(err); fail(err);
}) })
.on('close', function () { .on('close', function () {
@ -157,7 +159,7 @@ try {
fs.copyFileSync(tarPathTemp, tarPathCache); fs.copyFileSync(tarPathTemp, tarPathCache);
fs.unlinkSync(tarPathTemp); fs.unlinkSync(tarPathTemp);
} }
extractTarball(tarPathCache); extractTarball(tarPathCache, platformAndArch);
}); });
} }
}); });

View File

@ -39,7 +39,7 @@ const cachePath = function () {
const log = function (item) { const log = function (item) {
if (item instanceof Error) { if (item instanceof Error) {
console.error(`sharp: ${item.message}`); console.error(`sharp: Installation error: ${item.message}`);
} else { } else {
console.log(`sharp: ${item}`); console.log(`sharp: ${item}`);
} }

View File

@ -125,7 +125,7 @@ describe('libvips binaries', function () {
it('logs an error message', function (done) { it('logs an error message', function (done) {
console.error = function (msg) { console.error = function (msg) {
assert.strictEqual(msg, 'sharp: problem'); assert.strictEqual(msg, 'sharp: Installation error: problem');
done(); done();
}; };
libvips.log(new Error('problem')); libvips.log(new Error('problem'));