Skip to main content

exec API

The exec api module allows you to execute arbitrary shell commands.

Usage

import { exec } from '@replit/extensions';

Methods

exec.spawn

Spawns a command, with given arguments and environment variables. Takes in callbacks, and returns an object containing a promise that resolves when the command exits, and a dispose function to kill the process.

spawn(options: SpawnOptions): SpawnOutput

exec.exec

Executes a command in the shell, with given arguments and environment variables

exec(command: string, options: { env: Record<string, string> }): Promise<ExecResult>

Types

BaseSpawnOptions

PropertyType
argsstring[]
env?Record<string, string>
splitStderr?boolean

CombinedStderrSpawnOptions

PropertyType
argsstring[]
env?Record<string, string>
onOutput?Function
splitStderr?false

ExecResult

PropertyType
exitCodenumber
outputstring

SpawnOutput

PropertyType
disposeFunction
resultPromisePromise<SpawnResult>

SpawnResult

PropertyType
errornull │ string
exitCodenumber

SplitStderrSpawnOptions

PropertyType
argsstring[]
env?Record<string, string>
onStdErr?OutputStrCallback
onStdOut?OutputStrCallback
splitStderrtrue

OutputStrCallback

(output: string) => void

SpawnOptions

SplitStderrSpawnOptions | CombinedStderrSpawnOptions
Was this helpful?