mirror of
https://github.com/lune-org/lune.git
synced 2025-05-04 10:43:57 +01:00
15 lines
638 B
Text
15 lines
638 B
Text
local process = require("@lune/process")
|
|
|
|
local expected = "Hello from child process!"
|
|
|
|
local result = if process.os == "windows"
|
|
then process.exec("powershell", { "-Command", "$input" }, { stdio = { stdin = expected } })
|
|
else process.exec("xargs", { "echo" }, { stdio = { stdin = expected } })
|
|
|
|
local resultStdout = result.stdout
|
|
resultStdout = string.gsub(resultStdout, "^%s+", "") -- Trim leading whitespace
|
|
resultStdout = string.gsub(resultStdout, "%s+$", "") -- Trim trailing whitespace
|
|
assert(
|
|
resultStdout == expected,
|
|
"Stdin passing did not return proper output!" .. `\nExpected: {expected}` .. `\nReceived: {resultStdout}`
|
|
)
|