mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-03 10:11:15 +02:00
* refactor(cta): use `commander` instead of `minimst` * fix default * pin deps * update lock file * rearrange options * style changes * colorful help message * add missing `dev` option * style * use local api for tests * concise checks for vite and solid * update lock file * fix api formatting * improvements to updating json files * hopefully the last commit in this PR * fix eslint Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
37 lines
1000 B
TypeScript
37 lines
1000 B
TypeScript
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
import execa, { Options, ExecaChildProcess } from 'execa'
|
|
|
|
export const shell = async (
|
|
command: string,
|
|
args?: string[],
|
|
options?: Options,
|
|
log: boolean = false
|
|
): Promise<ExecaChildProcess> => {
|
|
try {
|
|
if (options && options.shell === true) {
|
|
const stringCommand = [command, ...(args ?? [])].join(' ')
|
|
if (log) console.log(`[running]: ${stringCommand}`)
|
|
return await execa(stringCommand, {
|
|
stdio: 'inherit',
|
|
cwd: process.cwd(),
|
|
env: process.env,
|
|
...options
|
|
})
|
|
} else {
|
|
if (log) console.log(`[running]: ${command}`)
|
|
return await execa(command, args, {
|
|
stdio: 'inherit',
|
|
cwd: process.cwd(),
|
|
env: process.env,
|
|
...options
|
|
})
|
|
}
|
|
} catch (error) {
|
|
console.error('Error with command: %s', command)
|
|
throw new Error(error)
|
|
}
|
|
}
|