From 4bce0df3018e919de81b399f7f9837ac752fb5f8 Mon Sep 17 00:00:00 2001 From: Rajiv Shah Date: Fri, 27 Dec 2019 06:06:55 -0500 Subject: [PATCH] fix(tauri.js): Various fixes to tauricon.ts (#237) * fix(tauri.js): Various fixes to tauricon.ts - Remove unnecessary awaits - Fix png2icons import - Avoid swallowing errors in icon generation * fix(test): test for correct error message Co-authored-by: nothingismagick --- cli/tauri.js/src/api/tauricon.ts | 11 ++++------- cli/tauri.js/test/jest/__tests__/tauricon.spec.js | 2 +- examples/Tauri-Phaser | 1 + 3 files changed, 6 insertions(+), 8 deletions(-) create mode 160000 examples/Tauri-Phaser diff --git a/cli/tauri.js/src/api/tauricon.ts b/cli/tauri.js/src/api/tauricon.ts index f839a1b96..77c43b190 100644 --- a/cli/tauri.js/src/api/tauricon.ts +++ b/cli/tauri.js/src/api/tauricon.ts @@ -19,7 +19,7 @@ import pngquant from 'imagemin-pngquant' import zopfli from 'imagemin-zopfli' import isPng from 'is-png' import path from 'path' -import png2icons from 'png2icons' +import * as png2icons from 'png2icons' import readChunk from 'read-chunk' import sharp from 'sharp' import { appDir, tauriDir } from '../helpers/app-paths' @@ -467,19 +467,16 @@ const tauricon = (exports.tauricon = { const sharpSrc = sharp(src) const buf = await sharpSrc.toBuffer() - // TODO: does this need to be awaited? - // eslint-disable-next-line @typescript-eslint/await-thenable - const out = await png2icons.createICNS(buf, png2icons.BICUBIC, 0) + const out = png2icons.createICNS(buf, png2icons.BICUBIC, 0) ensureFileSync(path.join(target, '/icon.icns')) writeFileSync(path.join(target, '/icon.icns'), out) - // TODO: does this need to be awaited? - // eslint-disable-next-line @typescript-eslint/await-thenable - const out2 = await png2icons.createICO(buf, png2icons.BICUBIC, 0, true) + const out2 = png2icons.createICO(buf, png2icons.BICUBIC, 0, true) ensureFileSync(path.join(target, '/icon.ico')) writeFileSync(path.join(target, '/icon.ico'), out2) } catch (err) { console.error(err) + throw err } } }) diff --git a/cli/tauri.js/test/jest/__tests__/tauricon.spec.js b/cli/tauri.js/test/jest/__tests__/tauricon.spec.js index f6219cbf3..31ee0557c 100644 --- a/cli/tauri.js/test/jest/__tests__/tauricon.spec.js +++ b/cli/tauri.js/test/jest/__tests__/tauricon.spec.js @@ -36,7 +36,7 @@ describe('[CLI] tauri-icon builder', () => { try { await tauricon.make('test/jest/fixtures/tauri-foo-not-found.png', 'test/jest/tmp/pngquant', 'pngquant') } catch (e) { - expect(e.message).toBe('[ERROR] Source image for tauricon not found') + expect(e.message).toBe('Input file is missing') } }) }) diff --git a/examples/Tauri-Phaser b/examples/Tauri-Phaser new file mode 160000 index 000000000..d06a4ed3d --- /dev/null +++ b/examples/Tauri-Phaser @@ -0,0 +1 @@ +Subproject commit d06a4ed3d246ccff841a1983741364eabce56b17