mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-09-21 21:28:24 +03:00
chore(cli.js): propagate all commands to cli.rs except icon
and deps
(#1604)
This commit is contained in:
parent
4d42548381
commit
9eccb2af28
@ -31,32 +31,10 @@ const tauri = async function (command) {
|
||||
command = command[0]
|
||||
}
|
||||
|
||||
if (rustCliCmds.includes(command)) {
|
||||
const { runOnRustCli } = require('../dist/helpers/rust-cli')
|
||||
if (process.argv && !process.env.test) {
|
||||
process.argv.splice(0, 3)
|
||||
}
|
||||
;(
|
||||
await runOnRustCli(
|
||||
command,
|
||||
(process.argv || []).filter((v) => v !== '--no-update-notifier')
|
||||
)
|
||||
).promise.then(() => {
|
||||
if (command === 'init' && !process.argv.some((arg) => arg === '--ci')) {
|
||||
const {
|
||||
installDependencies
|
||||
} = require('../dist/api/dependency-manager')
|
||||
return installDependencies()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
if (
|
||||
!command ||
|
||||
command === '-h' ||
|
||||
command === '--help' ||
|
||||
command === 'help'
|
||||
) {
|
||||
console.log(`
|
||||
const help =
|
||||
!command || command === '-h' || command === '--help' || command === 'help'
|
||||
if (help) {
|
||||
console.log(`
|
||||
${chalk.cyan(`
|
||||
:oooodddoooo; ;oddl, ,ol, ,oc, ,ldoooooooc, ,oc,
|
||||
';;;cxOx:;;;' ;xOxxko' :kx: lkd, :xkl;;;;:okx: lkd,
|
||||
@ -77,25 +55,36 @@ ${chalk.yellow('Options')}
|
||||
--version, -v Displays the Tauri CLI version
|
||||
`)
|
||||
|
||||
process.exit(0)
|
||||
// eslint-disable-next-line no-unreachable
|
||||
return false // do this for node consumers and tests
|
||||
process.exit(0)
|
||||
// eslint-disable-next-line no-unreachable
|
||||
return false // do this for node consumers and tests
|
||||
} else if (command === '-v' || command === '--version') {
|
||||
console.log(`${pkg.version}`)
|
||||
return false // do this for node consumers and tests
|
||||
} else if (cmds.includes(command)) {
|
||||
if (process.argv && !process.env.test) {
|
||||
process.argv.splice(2, 1)
|
||||
}
|
||||
|
||||
if (command === '-v' || command === '--version') {
|
||||
console.log(`${pkg.version}`)
|
||||
return false // do this for node consumers and tests
|
||||
console.log(`[tauri]: running ${command}`)
|
||||
require(`./tauri-${command}`)
|
||||
} else {
|
||||
const { runOnRustCli } = require('../dist/helpers/rust-cli')
|
||||
if (process.argv && !process.env.test) {
|
||||
process.argv.splice(0, 3)
|
||||
}
|
||||
|
||||
if (cmds.includes(command)) {
|
||||
if (process.argv && !process.env.test) {
|
||||
process.argv.splice(2, 1)
|
||||
;(
|
||||
await runOnRustCli(
|
||||
command,
|
||||
(process.argv || []).filter((v) => v !== '--no-update-notifier')
|
||||
)
|
||||
).promise.then(() => {
|
||||
if (command === 'init' && !process.argv.some((arg) => arg === '--ci')) {
|
||||
const {
|
||||
installDependencies
|
||||
} = require('../dist/api/dependency-manager')
|
||||
return installDependencies()
|
||||
}
|
||||
console.log(`[tauri]: running ${command}`)
|
||||
require(`./tauri-${command}`)
|
||||
} else {
|
||||
console.log(`Invalid command ${command}. Use one of ${cmds.join(', ')}.`)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,15 +17,6 @@ describe('[CLI] cli.js', () => {
|
||||
jest.clearAllMocks()
|
||||
})
|
||||
|
||||
it('will not run an unavailable command', async () => {
|
||||
jest.spyOn(console, 'log')
|
||||
tauri('foo')
|
||||
expect(console.log.mock.calls[0][0].split('.')[0]).toBe(
|
||||
'Invalid command foo'
|
||||
)
|
||||
jest.clearAllMocks()
|
||||
})
|
||||
|
||||
it('gets you help', async () => {
|
||||
jest.spyOn(console, 'log')
|
||||
const tests = ['--help', '-h', 'invalid command']
|
||||
|
Loading…
Reference in New Issue
Block a user