tauri.js 1020 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env node
  2. const cmds = ['init', 'dev', 'build', 'help', 'icon']
  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. `)
  23. process.exit(0)
  24. return false// do this for node consumers and tests
  25. }
  26. if (cmds.includes(command)) {
  27. if (process.argv) {
  28. process.argv.splice(2, 1)
  29. }
  30. console.log(`[tauri]: running ${command}`)
  31. require(`./tauri-${command}`)
  32. } else {
  33. console.log(`Invalid command ${command}. Use one of ${cmds.join(',')}.`)
  34. }
  35. }
  36. module.exports = { tauri }
  37. tauri(cmd)