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 <drthompsonsmagickindustries@gmail.com>
This commit is contained in:
Rajiv Shah 2019-12-27 06:06:55 -05:00 committed by nothingismagick
parent 5b15552ed5
commit 4bce0df301
3 changed files with 6 additions and 8 deletions

View File

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

View File

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

1
examples/Tauri-Phaser Submodule

@ -0,0 +1 @@
Subproject commit d06a4ed3d246ccff841a1983741364eabce56b17