Function: memorySpawn()
Documentation / @wtf/platform-memory / process / memorySpawn
function memorySpawn(script?, __namedParameters?): MemorySpawn;Defined in: packages/platform-memory/src/process.ts:51
A spawn whose processes script answers, recorded in runs as each is started: a process
reads its stdin to its end, then its script is given what it read, as text, its folder, cwd
of its options or else of the platform, and its environment, env of its options, whole, or
else the platform’s variables that are set. What the script answers is what the process wrote,
and its code; undefined is a command not there, whose status rejects with a SystemError of
NotFound. A process whose signal is aborted before it is answered ends at once, as one
SIGTERM ended: { code: 143, signal: 'SIGTERM' }. With no script, no command is there.
const spawn = memorySpawn((command, args) => (command === 'git' ? { stdout: 'main\n' } : undefined))await exec(spawn, 'git', ['branch', '--show-current']) // { stdout: 'main\n', stderr: '', code: 0 }spawn.runs // [{ command: 'git', args: ['branch', '--show-current'], cwd: '/', env: {} }]Parameters
| Parameter | Type | Description |
|---|---|---|
script | SpawnScript | - |
__namedParameters | { cwd?: () => string; env?: Readonly<Record<string, string | undefined>>; } | - |
__namedParameters.cwd? | () => string | The working folder of the platform, as it is when a process starts: / by default. |
__namedParameters.env? | Readonly<Record<string, string | undefined>> | The environment of the platform: none by default. |
