mirror of
https://github.com/lune-org/lune.git
synced 2025-04-07 20:10:55 +01:00
feat: rename process.spawn->process.create
This commit is contained in:
parent
70088c78e5
commit
0c346a5946
5 changed files with 11 additions and 11 deletions
|
@ -79,7 +79,7 @@ pub fn module(lua: &Lua) -> LuaResult<LuaTable> {
|
|||
.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()
|
||||
}
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue