fix: address todo comments

This commit is contained in:
Erica Marigold 2024-06-10 14:56:01 +05:30
parent 70583c6bf8
commit a30380cba8
No known key found for this signature in database
GPG key ID: 2768CC0C23D245D1
3 changed files with 3 additions and 34 deletions

View file

@ -224,7 +224,6 @@ async fn process_spawn(
.expect("ExitCode receiver was unexpectedly dropped");
});
// TODO: Remove the lua errors since we no longer accept stdio options for spawn
TableBuilder::new(lua)?
.with_value(
"stdout",
@ -232,9 +231,7 @@ async fn process_spawn(
stdout_rx
.await
.expect("Stdout sender unexpectedly dropped")
.ok_or(LuaError::runtime(
"Cannot read from stdout when it is not piped",
))?,
.unwrap(),
),
)?
.with_value(
@ -243,9 +240,7 @@ async fn process_spawn(
stderr_rx
.await
.expect("Stderr sender unexpectedly dropped")
.ok_or(LuaError::runtime(
"Cannot read from stderr when it is not piped",
))?,
.unwrap(),
),
)?
.with_value(
@ -284,10 +279,6 @@ async fn spawn_command(
let stderr = options.stdio.stderr;
let stdin = options.stdio.stdin.take();
// TODO: Have an stdin_kind which the user can supply as piped or not
// TODO: Maybe even revamp the stdout/stderr kinds? User should only use
// piped when they are sure they want to read the stdout. Currently we default
// to piped
let mut child = options
.into_command(program, args)
.stdin(Stdio::piped())

View file

@ -1,22 +0,0 @@
local process = require("@lune/process")
local stdio = require("@lune/stdio")
local task = require("@lune/task")
local child = process.spawn("echo", { "lsp" })
task.wait(1)
stdio.write(buffer.tostring(child.stdout:readToEnd()))
stdio.write(buffer.tostring(child.stdout:readToEnd()))
stdio.write(buffer.tostring(child.stdout:readToEnd()))
-- while true do
-- child.stdin:write("hello world")
-- local buf = child.stdout:read()
-- if buffer.len(buf) == 0 then
-- break
-- end
-- stdio.write(buffer.tostring(buf) .. "\n")
-- -- stdio.write(buffer.tostring(child.stderr:read() .. child.stderr:read() .. child.stderr:read() .. child.stderr:read()))
-- end

View file

@ -13,6 +13,6 @@ for _ = 1, SAMPLES do
local delta = os.time() - start
assert(
delta <= 1,
`Spawning a child process should not block the main thread, process.spawn took {delta}s to return it should return immediately`
`Spawning a child process should not block the main thread, process.spawn took {delta}s to return when it should return immediately`
)
end