diff --git a/crates/lune-std-process/src/lib.rs b/crates/lune-std-process/src/lib.rs index 9e0ee02..4212a77 100644 --- a/crates/lune-std-process/src/lib.rs +++ b/crates/lune-std-process/src/lib.rs @@ -79,7 +79,7 @@ pub fn module(lua: &Lua) -> LuaResult { .with_value("env", env_tab)? .with_value("exit", process_exit)? .with_async_function("exec", process_exec)? - .with_async_function("spawn", process_spawn)? + .with_async_function("create", process_spawn)? .build_readonly() } diff --git a/tests/process/spawn/non_blocking.luau b/tests/process/spawn/non_blocking.luau index 39d8783..d44a9d2 100644 --- a/tests/process/spawn/non_blocking.luau +++ b/tests/process/spawn/non_blocking.luau @@ -6,7 +6,7 @@ local SAMPLES = 400 for _ = 1, SAMPLES do local start = os.time() - local child = process.spawn("echo", { "hello, world" }) + local child = process.create("echo", { "hello, world" }) assert(child ~= nil, "Failed to spawn child process") diff --git a/tests/process/spawn/status.luau b/tests/process/spawn/status.luau index 0da2d99..418c132 100644 --- a/tests/process/spawn/status.luau +++ b/tests/process/spawn/status.luau @@ -4,7 +4,7 @@ local process = require("@lune/process") local randomExitCode = math.random(0, 255) local isOk = randomExitCode == 0 -local child = process.spawn("exit", { tostring(randomExitCode) }, { shell = true }) +local child = process.create("exit", { tostring(randomExitCode) }, { shell = true }) local status = child.status() assert( diff --git a/tests/process/spawn/stream.luau b/tests/process/spawn/stream.luau index ce5f728..965eab1 100644 --- a/tests/process/spawn/stream.luau +++ b/tests/process/spawn/stream.luau @@ -4,7 +4,7 @@ local process = require("@lune/process") local msg = "hello, world" -local catChild = process.spawn("cat") +local catChild = process.create("cat") catChild.stdin:write(msg) assert( msg == catChild.stdout:read(#msg), @@ -12,8 +12,8 @@ assert( ) local echoChild = if process.os == "windows" - then process.spawn("/c", { "echo", msg, "1>&2" }, { shell = "cmd" }) - else process.spawn("echo", { msg, ">>/dev/stderr" }, { shell = true }) + then process.create("/c", { "echo", msg, "1>&2" }, { shell = "cmd" }) + else process.create("echo", { msg, ">>/dev/stderr" }, { shell = true }) assert( msg == echoChild.stderr:read(#msg), diff --git a/types/process.luau b/types/process.luau index 8161de1..7e9f50b 100644 --- a/types/process.luau +++ b/types/process.luau @@ -15,7 +15,7 @@ export type ExecuteOptionsStdio = SpawnOptionsStdio & { @interface SpawnOptions @within Process - A dictionary of options for `process.spawn`, with the following available values: + A dictionary of options for `process.create`, with the following available values: * `cwd` - The current working directory for the process * `env` - Extra environment variables to give to the process @@ -103,7 +103,7 @@ end @interface SpawnResult @within Process - Result type for child processes in `process.spawn`. + Result type for child processes in `process.create`. This is a dictionary containing the following values: @@ -176,7 +176,7 @@ export type ExecuteResult = { end -- Spawning a child process - local child = process.spawn("program", { + local child = process.create("program", { "cli argument", "other cli argument" }) @@ -282,7 +282,7 @@ end @param options A dictionary of options for the child process @return A dictionary with the readers and writers to communicate with the child process ]=] -function process.spawn(program: string, params: { string }?, options: SpawnOptions?): ChildProcess +function process.create(program: string, params: { string }?, options: SpawnOptions?): ChildProcess return nil :: any end @@ -292,7 +292,7 @@ end Executes a child process that will execute the command `program`, waiting for it to exit. Upon exit, it returns a dictionary that describes the final status and ouput of the child process. - In order to spawn a child process in the background, see `process.spawn`. + In order to spawn a child process in the background, see `process.create`. The second argument, `params`, can be passed as a list of string parameters to give to the program.