Skip to main content

LensStudio:Subprocess.SpawnOptions

Class

The options of "LensStudio:Subprocess".spawn or "LensStudio:Subprocess".spawnSync.

The options of "LensStudio:Subprocess".spawn or "LensStudio:Subprocess".spawnSync. env, can be specified as a {PATH: myPath, PWD: myPwd} or a JS object. The PATH and PWD fields will override the default value in your environment has when the subprocess is spawned. You can access the default environment variables from "LensStudio:App", where its a constant value that you can retrieve just like .version, using .env.

Index

Example

const Subprocess = await import('LensStudio:Subprocess');

// SpawnOptions configures how a subprocess is launched.
// Properties:
// cwd – Editor.Path – working directory for the spawned process
// env – any – environment variables passed to the process
// timeout – number – milliseconds to wait (spawnSync); default 30000

// spawnSync uses SpawnOptions internally; demonstrate via spawnSync
const result = Subprocess.spawnSync('echo', ['hello'], {} as any);
console.log(`SpawnOptions: spawnSync exitCode = ${result.exitCode}`);
console.log(`SpawnOptions: stdout length = ${result.stdout.toString().length}`);

Properties

cwd

cwd: Path

Working directory path for the spawned process.


env

env: any

Environment variables for the spawned process.


timeout

timeout: number

Maximum time in milliseconds for the process to complete.