tauri-icon.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. t: 'target'
  27. },
  28. boolean: ['h', 'l']
  29. })
  30. if (argv.help) {
  31. console.log(`
  32. Description
  33. Create all the icons you need for your Tauri app.
  34. The icon path is the source icon (png, 1240x1240 with transparency).
  35. Usage
  36. $ tauri icon [ICON-PATH]
  37. Options
  38. --help, -h Displays this message
  39. --log, l Logging [boolean]
  40. --target, t Target folder (default: 'src-tauri/icons')
  41. --compression, c Compression type [pngquant|optipng|zopfli]
  42. `)
  43. process.exit(0)
  44. }
  45. tauricon
  46. .make(argv._[0], argv.t, argv.c || 'optipng')
  47. .then(() => {
  48. // TODO: use logger module for prettier output
  49. console.log('app:tauri (tauricon) Completed')
  50. })
  51. .catch((e) => {
  52. // TODO: use logger module for prettier output
  53. console.error('app:tauri (icon)', e)
  54. })