(cmd: string, args?: ReadonlyArray<string>, options?: CommandOptions): (
token: string
) => ChildProcess.CommandBuild a SpawnSpec.process factory that injects the assume token into env and/or argv.
export const const command: (
cmd: string,
args?: ReadonlyArray<string>,
options?: CommandOptions
) => (token: string) => ChildProcess.Command
Build a SpawnSpec.process factory that injects the assume token into env and/or argv.
command = (
cmd: stringcmd: string,
args: readonly string[]args: interface ReadonlyArray<T>ReadonlyArray<string> = [],
options: CommandOptionsoptions?: CommandOptions,
): ((token: stringtoken: string) => import ChildProcessChildProcess.type Command =
| ChildProcess.StandardCommand
| ChildProcess.PipedCommand
A command that can be built using make, combined using pipeTo, and executed using exec or spawn.
Command) => {
const const injection: TokenInjectioninjection: type TokenInjection =
| "env"
| "argv"
| "both"
How the assume token is injected into the child process.
TokenInjection = options: CommandOptionsoptions?.CommandOptions.token?: TokenInjectionWhere to put the minted assume token. Default "env" → HYPERLINK_ASSUME_TOKEN.
"argv" appends the token as the last argument; "both" does both.
token ?? "env";
const {
CommandOptions.token?: TokenInjectionWhere to put the minted assume token. Default "env" → HYPERLINK_ASSUME_TOKEN.
"argv" appends the token as the last argument; "both" does both.
token: const _tokenMode:
| TokenInjection
| undefined
Where to put the minted assume token. Default "env" → HYPERLINK_ASSUME_TOKEN.
"argv" appends the token as the last argument; "both" does both.
_tokenMode,
CommandOptions.env?: Record<string, string | undefined> | undefinedThe environment of the child process.
Details
If extendEnv is set to true, the value of env will be merged with
the value of globalThis.process.env, prioritizing the values in env
when conflicts exist.
env: const baseEnv:
| Record<string, string | undefined>
| undefined
The environment of the child process.
Details
If extendEnv is set to true, the value of env will be merged with
the value of globalThis.process.env, prioritizing the values in env
when conflicts exist.
baseEnv,
const extendEnv: boolean | undefinedIf set to true, the child process uses both the values in env as well
as the values in globalThis.process.env, prioritizing the values in env
when conflicts exist.
Details
If set to false, only the value of env is used.
extendEnv,
...const rest: {
cwd?: string | undefined
shell?: boolean | string | undefined
detached?: boolean | undefined
stdin?:
| ChildProcess.CommandInput
| ChildProcess.StdinConfig
| undefined
stdout?:
| ChildProcess.CommandOutput
| ChildProcess.StdoutConfig
| undefined
stderr?:
| ChildProcess.CommandOutput
| ChildProcess.StderrConfig
| undefined
additionalFds?:
| Record<
`fd${number}`,
ChildProcess.AdditionalFdConfig
>
| undefined
killSignal?: ChildProcess.Signal | undefined
forceKillAfter?: Duration.Input | undefined
}
rest
} = options: CommandOptionsoptions ?? {};
return (clearToken: stringclearToken: string) => {
const const argv: string[]argv =
const injection: TokenInjectioninjection === "argv" || const injection: TokenInjectioninjection === "both"
? [...args: readonly string[]args, clearToken: stringclearToken]
: [...args: readonly string[]args];
const const env:
| Record<string, string | undefined>
| undefined
env =
const injection: TokenInjectioninjection === "env" || const injection: TokenInjectioninjection === "both"
? { ...(const baseEnv:
| Record<string, string | undefined>
| undefined
The environment of the child process.
Details
If extendEnv is set to true, the value of env will be merged with
the value of globalThis.process.env, prioritizing the values in env
when conflicts exist.
baseEnv ?? {}), [const ASSUME_TOKEN_ENV: "HYPERLINK_ASSUME_TOKEN"Default env / Config name for local Node token injection sugar.
ASSUME_TOKEN_ENV]: clearToken: stringclearToken }
: const baseEnv:
| Record<string, string | undefined>
| undefined
The environment of the child process.
Details
If extendEnv is set to true, the value of env will be merged with
the value of globalThis.process.env, prioritizing the values in env
when conflicts exist.
baseEnv;
return import ChildProcessChildProcess.const make: (command: string, args: ReadonlyArray<string>, options?: ChildProcess.CommandOptions) => ChildProcess.StandardCommand (+3 overloads)Create a command from a template literal, options + template, or array form.
Details
This function supports three calling conventions:
- Template literal:
make\npm run build``
- Options + template literal:
make({ cwd: "/app" })\npm run build``
- Array form:
make("npm", ["run", "build"], options?)
Template literals are not parsed until execution time, allowing parsing
errors to flow through Effect's error channel.
Example (Creating commands)
import { ChildProcess } from "effect/unstable/process"
// Template literal form
const cmd1 = ChildProcess.make`echo "hello"`
// With options
const cmd2 = ChildProcess.make({ cwd: "/tmp" })`ls -la`
// Array form
const cmd3 = ChildProcess.make("git", ["status"])
make(cmd: stringcmd, const argv: string[]argv, {
...const rest: {
cwd?: string | undefined
shell?: boolean | string | undefined
detached?: boolean | undefined
stdin?:
| ChildProcess.CommandInput
| ChildProcess.StdinConfig
| undefined
stdout?:
| ChildProcess.CommandOutput
| ChildProcess.StdoutConfig
| undefined
stderr?:
| ChildProcess.CommandOutput
| ChildProcess.StderrConfig
| undefined
additionalFds?:
| Record<
`fd${number}`,
ChildProcess.AdditionalFdConfig
>
| undefined
killSignal?: ChildProcess.Signal | undefined
forceKillAfter?: Duration.Input | undefined
}
rest,
...(const env:
| Record<string, string | undefined>
| undefined
env !== var undefinedundefined ? { CommandOptions.env?: Record<string, string | undefined> | undefinedThe environment of the child process.
Details
If extendEnv is set to true, the value of env will be merged with
the value of globalThis.process.env, prioritizing the values in env
when conflicts exist.
env } : {}),
// Default merge with process env so PATH / etc. survive token injection.
CommandOptions.extendEnv?: boolean | undefinedIf set to true, the child process uses both the values in env as well
as the values in globalThis.process.env, prioritizing the values in env
when conflicts exist.
Details
If set to false, only the value of env is used.
extendEnv: const extendEnv: boolean | undefinedIf set to true, the child process uses both the values in env as well
as the values in globalThis.process.env, prioritizing the values in env
when conflicts exist.
Details
If set to false, only the value of env is used.
extendEnv ?? true,
});
};
};