@01/launcher 中文文档教程
Nodejs Process Launcher
Usage
import {launch} from '@1/launcher'
await launch({
cmds:['echo', 'Hello']
})
Options
type Options = {
env?: string | string[];
cmds?: string[];
cwd?: string;
mode?: LaunchMode;
exitProcessOnClose?: boolean;
silent?: boolean;
} & SpawnOptions;
env
将自定义环境变量传递给子进程的选项。
env:'ENV_VAR=value'
env:['ENV1=v1', 'ENV2=v2']
env:'ENV1=v1,ENV2=v2'
cmds
带参数的子进程 cmd。 第一个元素是程序位置或名称,其余元素是它的参数。
cmds: ['echo', 'Hello']
cwd
当前工作目录。 如果路径以斜杠 /
开头,则为绝对路径,否则为相对路径。
cwd: './relative/path'
cwd: '/absolute/path'
mode
启动模式
cli
Exit program on exceptionsprogram
Throw error on exceptions
exitProcessOnClose
关闭时退出父节点进程。
silent
跳过详细日志
Nodejs Process Launcher
Usage
import {launch} from '@1/launcher'
await launch({
cmds:['echo', 'Hello']
})
Options
type Options = {
env?: string | string[];
cmds?: string[];
cwd?: string;
mode?: LaunchMode;
exitProcessOnClose?: boolean;
silent?: boolean;
} & SpawnOptions;
env
Option to pass custom environment variable to child process.
env:'ENV_VAR=value'
env:['ENV1=v1', 'ENV2=v2']
env:'ENV1=v1,ENV2=v2'
cmds
Child process cmd with arguments. First element is the program location or name and remaining elements are it's arguments.
cmds: ['echo', 'Hello']
cwd
Current working directory. Path is absolute if it's starts with slash /
otherwise relative.
cwd: './relative/path'
cwd: '/absolute/path'
mode
Launch mode
cli
Exit program on exceptionsprogram
Throw error on exceptions
exitProcessOnClose
Exit parent node process on close.
silent
Skip verbose logs
更多