From fe0767df13a1610390961a10f5d5c1080213c1b1 Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Thu, 1 Apr 2021 16:20:58 +0100 Subject: [PATCH] Install: log errors with more obvious prefix --- docs/changelog.md | 4 ++++ install/libvips.js | 6 ++++-- lib/libvips.js | 2 +- test/unit/libvips.js | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index b87ea5e4..30b342a7 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -4,6 +4,10 @@ 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 * Prebuilt binaries now include mozjpeg and libimagequant (BSD 2-Clause). diff --git a/install/libvips.js b/install/libvips.js index 35f68fd1..2dd86a72 100644 --- a/install/libvips.js +++ b/install/libvips.js @@ -145,7 +145,9 @@ try { tmpFileStream .on('error', function (err) { // Clean up temporary file - fs.unlinkSync(tarPathTemp); + try { + fs.unlinkSync(tarPathTemp); + } catch (e) {} fail(err); }) .on('close', function () { @@ -157,7 +159,7 @@ try { fs.copyFileSync(tarPathTemp, tarPathCache); fs.unlinkSync(tarPathTemp); } - extractTarball(tarPathCache); + extractTarball(tarPathCache, platformAndArch); }); } }); diff --git a/lib/libvips.js b/lib/libvips.js index 6ee0554b..8a6dac2d 100644 --- a/lib/libvips.js +++ b/lib/libvips.js @@ -39,7 +39,7 @@ const cachePath = function () { const log = function (item) { if (item instanceof Error) { - console.error(`sharp: ${item.message}`); + console.error(`sharp: Installation error: ${item.message}`); } else { console.log(`sharp: ${item}`); } diff --git a/test/unit/libvips.js b/test/unit/libvips.js index 60d56658..29eb69c9 100644 --- a/test/unit/libvips.js +++ b/test/unit/libvips.js @@ -125,7 +125,7 @@ describe('libvips binaries', function () { it('logs an error message', function (done) { console.error = function (msg) { - assert.strictEqual(msg, 'sharp: problem'); + assert.strictEqual(msg, 'sharp: Installation error: problem'); done(); }; libvips.log(new Error('problem'));