Command
Defined in: index.ts:374
The entry point for spawning child processes.
It emits the close
and error
events.
import { Command } from '@tauri-apps/plugin-shell';const command = Command.create('node');command.on('close', data => { console.log(`command finished with code ${data.code} and signal ${data.signal}`)});command.on('error', error => console.error(`command error: "${error}"`));command.stdout.on('data', line => console.log(`command stdout: "${line}"`));command.stderr.on('data', line => console.log(`command stderr: "${line}"`));
const child = await command.spawn();console.log('pid:', child.pid);
2.0.0
O
extends IOPayload
readonly
stderr:EventEmitter
<OutputEvents
<O
>>
Defined in: index.ts:384
Event emitter for the stderr
. Emits the data
event.
readonly
stdout:EventEmitter
<OutputEvents
<O
>>
Defined in: index.ts:382
Event emitter for the stdout
. Emits the data
event.
addListener<
N
>(eventName
,listener
):this
Defined in: index.ts:118
Alias for emitter.on(eventName, listener)
.
N
extends keyof CommandEvents
N
(arg
) => void
this
2.0.0
execute():
Promise
<ChildProcess
<O
>>
Defined in: index.ts:530
Executes the command as a child process, waiting for it to finish and collecting all of its output.
Promise
<ChildProcess
<O
>>
A promise resolving to the child process output.
import { Command } from '@tauri-apps/plugin-shell';const output = await Command.create('echo', 'message').execute();assert(output.code === 0);assert(output.signal === null);assert(output.stdout === 'message');assert(output.stderr === '');
2.0.0
listenerCount<
N
>(eventName
):number
Defined in: index.ts:241
Returns the number of listeners listening to the event named eventName
.
N
extends keyof CommandEvents
N
number
2.0.0
off<
N
>(eventName
,listener
):this
Defined in: index.ts:186
Removes the all specified listener from the listener array for the event eventName
Returns a reference to the EventEmitter
, so that calls can be chained.
N
extends keyof CommandEvents
N
(arg
) => void
this
2.0.0
on<
N
>(eventName
,listener
):this
Defined in: index.ts:147
Adds the listener
function to the end of the listeners array for the
event named eventName
. No checks are made to see if the listener
has
already been added. Multiple calls passing the same combination of eventName
and listener
will result in the listener
being added, and called, multiple
times.
Returns a reference to the EventEmitter
, so that calls can be chained.
N
extends keyof CommandEvents
N
(arg
) => void
this
2.0.0
once<
N
>(eventName
,listener
):this
Defined in: index.ts:169
Adds a one-timelistener
function for the event named eventName
. The
next time eventName
is triggered, this listener is removed and then invoked.
Returns a reference to the EventEmitter
, so that calls can be chained.
N
extends keyof CommandEvents
N
(arg
) => void
this
2.0.0
prependListener<
N
>(eventName
,listener
):this
Defined in: index.ts:258
Adds the listener
function to the beginning of the listeners array for the
event named eventName
. No checks are made to see if the listener
has
already been added. Multiple calls passing the same combination of eventName
and listener
will result in the listener
being added, and called, multiple
times.
Returns a reference to the EventEmitter
, so that calls can be chained.
N
extends keyof CommandEvents
N
(arg
) => void
this
2.0.0
prependOnceListener<
N
>(eventName
,listener
):this
Defined in: index.ts:280
Adds a one-timelistener
function for the event named eventName
to the_beginning_ of the listeners array. The next time eventName
is triggered, this
listener is removed, and then invoked.
Returns a reference to the EventEmitter
, so that calls can be chained.
N
extends keyof CommandEvents
N
(arg
) => void
this
2.0.0
EventEmitter
.prependOnceListener
removeAllListeners<
N
>(event?
):this
Defined in: index.ts:206
Removes all listeners, or those of the specified eventName.
Returns a reference to the EventEmitter
, so that calls can be chained.
N
extends keyof CommandEvents
N
this
2.0.0
EventEmitter
.removeAllListeners
removeListener<
N
>(eventName
,listener
):this
Defined in: index.ts:130
Alias for emitter.off(eventName, listener)
.
N
extends keyof CommandEvents
N
(arg
) => void
this
2.0.0
spawn():
Promise
<Child
>
Defined in: index.ts:479
Executes the command as a child process, returning a handle to it.
Promise
<Child
>
A promise resolving to the child process handle.
2.0.0
Creates a command to execute the given program.
import { Command } from '@tauri-apps/plugin-shell';const command = Command.create('my-app', ['run', 'tauri']);const output = await command.execute();
The program to execute. It must be configured in your project’s capabilities.
static
create(program
,args?
):Command
<string
>
Defined in: index.ts:406
string
string
| string
[]
Command
<string
>
static
create(program
,args?
,options?
):Command
<Uint8Array
<ArrayBufferLike
>>
Defined in: index.ts:407
string
string
| string
[]
SpawnOptions
& object
Command
<Uint8Array
<ArrayBufferLike
>>
static
create(program
,args?
,options?
):Command
<string
>
Defined in: index.ts:412
string
string
| string
[]
Command
<string
>
Creates a command to execute the given sidecar program.
import { Command } from '@tauri-apps/plugin-shell';const command = Command.sidecar('my-sidecar');const output = await command.execute();
The program to execute. It must be configured in your project’s capabilities.
static
sidecar(program
,args?
):Command
<string
>
Defined in: index.ts:438
string
string
| string
[]
Command
<string
>
static
sidecar(program
,args?
,options?
):Command
<Uint8Array
<ArrayBufferLike
>>
Defined in: index.ts:439
string
string
| string
[]
SpawnOptions
& object
Command
<Uint8Array
<ArrayBufferLike
>>
static
sidecar(program
,args?
,options?
):Command
<string
>
Defined in: index.ts:444
string
string
| string
[]
Command
<string
>
© 2025 Tauri Contributors. CC-BY / MIT