tauri.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/usr/bin/env node
  2. const cmds = ['init', 'dev', 'build', 'help', 'icon', 'info']
  3. const cmd = process.argv[2]
  4. /**
  5. * @description This is the bootstrapper that in turn calls subsequent
  6. * Tauri Commands
  7. *
  8. * @param {string|array} command
  9. */
  10. const tauri = function (command) {
  11. if (typeof command === 'object') { // technically we just care about an array
  12. command = command[0]
  13. }
  14. if (!command || command === '-h' || command === '--help' || command === 'help') {
  15. console.log(`
  16. Description
  17. This is the Tauri CLI.
  18. Usage
  19. $ tauri ${cmds.join('|')}
  20. Options
  21. --help, -h Displays this message
  22. --version, -v Displays the Tauri CLI version
  23. `)
  24. process.exit(0)
  25. // eslint-disable-next-line no-unreachable
  26. return false // do this for node consumers and tests
  27. }
  28. if (command === '-v' || command === '--version') {
  29. console.log(require('../package.json').version)
  30. return false // do this for node consumers and tests
  31. }
  32. if (cmds.includes(command)) {
  33. if (process.argv && !process.env.test) {
  34. process.argv.splice(2, 1)
  35. }
  36. console.log(`[tauri]: running ${command}`)
  37. // eslint-disable-next-line security/detect-non-literal-require
  38. require(`./tauri-${command}`)
  39. } else {
  40. console.log(`Invalid command ${command}. Use one of ${cmds.join(',')}.`)
  41. }
  42. }
  43. module.exports = { tauri }
  44. tauri(cmd)