2023-10-06 02:53:29 +01:00
|
|
|
local process = require("@lune/process")
|
|
|
|
|
|
|
|
local IS_WINDOWS = process.os == "windows"
|
|
|
|
|
|
|
|
-- Inheriting stdio & environment variables should work
|
|
|
|
|
|
|
|
local echoMessage = "Hello from child process!"
|
2024-10-16 20:48:12 +01:00
|
|
|
local echoResult = process.exec("echo", {
|
2023-10-06 02:53:29 +01:00
|
|
|
if IS_WINDOWS then '"$Env:TEST_VAR"' else '"$TEST_VAR"',
|
|
|
|
}, {
|
|
|
|
env = { TEST_VAR = echoMessage },
|
|
|
|
shell = if IS_WINDOWS then "powershell" else "bash",
|
2024-10-16 20:48:12 +01:00
|
|
|
stdio = "inherit" :: process.SpawnOptionsStdioKind, -- FIXME: This should just work without a cast?
|
2023-10-06 02:53:29 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
-- Windows uses \r\n (CRLF) and unix uses \n (LF)
|
|
|
|
|
|
|
|
local echoTrail = if IS_WINDOWS then "\r\n" else "\n"
|
|
|
|
assert(
|
|
|
|
echoResult.stdout == (echoMessage .. echoTrail),
|
|
|
|
"Inheriting stdio did not return proper output"
|
|
|
|
)
|