Effection Logo
@effectionx/processv0.5.0thefrontside/effectionx
JSR BadgeNPM Badge with published versionBundle size badgeDependency count badgeTree shaking support badge

@effection/process

License: MIT Created by Frontside Chat on Discord

Effection is the structured concurrency toolkit for JavaScript. You can find detailed information about using effection to manage system process in node in the spawning processes guide

API Reference

interface Daemon extends Operation<void>, Process

function daemon(command: string, ): Operation<Daemon>

Start a long-running process, like a web server that run perpetually. Daemon operations are expected to run forever, and if they exit pre-maturely before the operation containing them passes out of scope it raises an error.

Parameters

command: string

Return Type

Operation<Daemon>

interface Exec extends Operation<Process>

Methods

join
(): Operation<ProcessResult>

No documentation available.

expect
(): Operation<ProcessResult>

No documentation available.

function exec(command: string, ): Exec

Execute command with options. You should use this operation for processes that have a finite lifetime and on which you may wish to synchronize on the exit status. If you want to start a process like a server that spins up and runs forever, consider using daemon()

Parameters

command: string

Return Type

Exec

interface Writable<T>

Type Parameters

T

Methods

send
(message: T): void

No documentation available.

interface Process extends StdIO

The process type is what is returned by the exec operation. It has all of standard io handles, and methods for synchronizing on return.

Properties

pidreadonly: number

No documentation available.

Methods

join
(): Operation<ExitStatus>

Completes once the process has finished regardless of whether it was successful or not.

expect
(): Operation<ExitStatus>

Completes once the process has finished successfully. If the process does not complete successfully, it will raise an ExecError.

interface ExecOptions

Properties

argumentsoptional: string[]

When not using passing the shell option all arguments must be passed as an array.

envoptional: Record<string, string>

Map of environment variables to use for the process.

shelloptional: boolean | string

Create an intermediate shell process; defaults to false. Useful if you need to handle glob expansion or passing environment variables. A truthy value will use an intermediate shell to interpret the command using the default system shell. However, if the value is a string, that will be used as the executable path for the intermediate shell.

cwdoptional: string

Sets the working directory of the process

interface StdIO

Properties

stdout: OutputStream

No documentation available.

stderr: OutputStream

No documentation available.

stdin: Writable<string>

No documentation available.

interface ExitStatus

Properties

codeoptional: number

exit code //TODO: is this pertinent on Windows? Do we need an 'OK' flag

signaloptional: string

If the process exited with a signal instead of an exit code, it is recorded here.

interface ProcessResult extends ExitStatus

Properties

stdout: string

No documentation available.

stderr: string

No documentation available.

interface CreateOSProcess

class ExecError extends Error implements

Constructors

new ExecError(status: ExitStatus, command: string, options: ExecOptions)

Methods

message(): string

No documentation available.

class DaemonExitError extends ExecError implements

Methods

message(): string

No documentation available.