diff --git a/crates/lune-std-process/src/lib.rs b/crates/lune-std-process/src/lib.rs index 04286ff..3e5e163 100644 --- a/crates/lune-std-process/src/lib.rs +++ b/crates/lune-std-process/src/lib.rs @@ -264,7 +264,7 @@ async fn process_spawn( TableBuilder::new(lua)? .with_value("code", code)? - .with_value("success", code == 0)? + .with_value("ok", code == 0)? .build_readonly() } })? diff --git a/crates/lune-std-process/src/stream.rs b/crates/lune-std-process/src/stream.rs index df46d6e..9a67e0e 100644 --- a/crates/lune-std-process/src/stream.rs +++ b/crates/lune-std-process/src/stream.rs @@ -17,6 +17,12 @@ impl ChildProcessReader { Ok(buf.to_vec()) } + + pub async fn read_to_end(&mut self) -> LuaResult> { + let mut buf = vec![]; + self.0.read_to_end(&mut buf).await?; + Ok(buf) + } } impl LuaUserData for ChildProcessReader { @@ -24,6 +30,10 @@ impl LuaUserData for ChildProcessReader { methods.add_async_method_mut("read", |lua, this, ()| async { Ok(lua.create_buffer(this.read().await?)) }); + + methods.add_async_method_mut("readToEnd", |lua, this, ()| async { + Ok(lua.create_buffer(this.read_to_end().await?)) + }); } } diff --git a/test.luau b/test.luau index 983c0a3..a7f5dec 100644 --- a/test.luau +++ b/test.luau @@ -1,7 +1,7 @@ local process = require("@lune/process") -local a = process.spawn("yes", {}) +local a = process.spawn("echo", {"hello"}) print(a) -print(buffer.tostring(a.stdout:read())) +print(buffer.tostring(a.stdout:readToEnd())) print(a.status()) \ No newline at end of file