tauri-icon.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright 2019-2021 Tauri Programme within The Commons Conservancy
  2. // SPDX-License-Identifier: Apache-2.0
  3. // SPDX-License-Identifier: MIT
  4. const parseArgs = require('minimist')
  5. const { tauricon } = require('../dist/api/tauricon')
  6. /**
  7. * @type {object}
  8. * @property {boolean} h
  9. * @property {boolean} help
  10. * @property {string|boolean} f
  11. * @property {string|boolean} force
  12. * @property {boolean} l
  13. * @property {boolean} log
  14. * @property {boolean} c
  15. * @property {boolean} config
  16. * @property {boolean} s
  17. * @property {boolean} source
  18. * @property {boolean} t
  19. * @property {boolean} target
  20. */
  21. const argv = parseArgs(process.argv.slice(2), {
  22. alias: {
  23. h: 'help',
  24. l: 'log',
  25. c: 'config',
  26. i: 'icon',
  27. t: 'target'
  28. },
  29. boolean: ['h', 'l']
  30. })
  31. if (argv.help) {
  32. console.log(`
  33. Description
  34. Create all the icons you need for your Tauri app.
  35. Usage
  36. $ tauri icon
  37. Options
  38. --help, -h Displays this message
  39. --log, l Logging [boolean]
  40. --icon, i Source icon (png, 1240x1240 with transparency)
  41. --target, t Target folder (default: 'src-tauri/icons')
  42. --compression, c Compression type [pngquant|optipng|zopfli]
  43. `)
  44. process.exit(0)
  45. }
  46. tauricon
  47. .make(argv.i, argv.t, argv.c || 'optipng')
  48. .then(() => {
  49. // TODO: use logger module for prettier output
  50. console.log('app:tauri (tauricon) Completed')
  51. })
  52. .catch((e) => {
  53. // TODO: use logger module for prettier output
  54. console.error('app:tauri (icon)', e)
  55. })