mirror of
https://github.com/pesde-pkg/tooling.git
synced 2025-05-04 10:43:58 +01:00
chore: migrate to process.exec
for lune v0.9.0
This commit is contained in:
parent
690d3ffbf1
commit
4eba797b8d
3 changed files with 12 additions and 14 deletions
|
@ -78,7 +78,7 @@ function CommandBuilder.withStdioStrategy(
|
|||
return self
|
||||
end
|
||||
|
||||
local function intoSpawnOptionsStdioKind(strategy: StdioStrategy): process.SpawnOptionsStdioKind
|
||||
local function intoSpawnOptionsStdioKind(strategy: StdioStrategy): process.ExecStdioKind
|
||||
if strategy == "pipe" then
|
||||
return "default"
|
||||
end
|
||||
|
@ -94,18 +94,18 @@ local function intoSpawnOptionsStdioKind(strategy: StdioStrategy): process.Spawn
|
|||
error(`Non-strategy provided: {strategy}`)
|
||||
end
|
||||
|
||||
function CommandBuilder.exec(self: CommandBuilder): process.SpawnResult
|
||||
function CommandBuilder.exec(self: CommandBuilder): process.ExecResult
|
||||
print(
|
||||
stdio.style("bold") .. "$",
|
||||
stdio.style("dim") .. self.program,
|
||||
table.concat(self.args, " ") .. stdio.style("reset")
|
||||
)
|
||||
local child = process.spawn(self.program, self.args, {
|
||||
local child = process.exec(self.program, self.args, {
|
||||
shell = if process.os == "windows" then "cmd.exe" else "bash",
|
||||
stdio = self.stdioStrategy
|
||||
:orOpt(Option.Some(DEFAULT_STDIO_STRATEGY))
|
||||
:map(function(mappings: IoStrategyMapping)
|
||||
local translatedMappings: process.SpawnOptionsStdio = {}
|
||||
local translatedMappings: any = {} -- FIXME: remove this any
|
||||
for field, value in mappings do
|
||||
translatedMappings[field] = intoSpawnOptionsStdioKind((value :: Option<StdioStrategy>):unwrap())
|
||||
end
|
||||
|
|
|
@ -78,10 +78,8 @@ local function chmod(path: pathfs.Path, mode: number | string)
|
|||
return
|
||||
end
|
||||
|
||||
local result = process.spawn(
|
||||
"chmod",
|
||||
{ if typeof(mode) == "string" then mode else string.format("%o", mode), path:toString() }
|
||||
)
|
||||
local result =
|
||||
process.exec("chmod", { if typeof(mode) == "string" then mode else string.format("%o", mode), path:toString() })
|
||||
|
||||
if not result.ok then
|
||||
return error(result.stderr)
|
||||
|
@ -117,14 +115,14 @@ local bar = ProgressBar.new()
|
|||
:withStage("install", "Installing")
|
||||
|
||||
function runTool(tool: ToolId | pathfs.Path): number
|
||||
-- FIXME: `process.spawn` has a bug where interactive features don't
|
||||
-- FIXME: `process.exec` has a bug where interactive features don't
|
||||
-- forward properly
|
||||
local toolId = tool :: ToolId
|
||||
local path = if (toolId :: any).alias ~= nil
|
||||
then LINK_INSTALL_DIR:join(toolAliasOrDefault(toolId))
|
||||
else tool :: pathfs.Path
|
||||
|
||||
return process.spawn(path:toString(), process.args, {
|
||||
return process.exec(path:toString(), process.args, {
|
||||
cwd = process.cwd,
|
||||
env = process.env,
|
||||
stdio = "forward",
|
||||
|
@ -153,8 +151,8 @@ end
|
|||
|
||||
local function getGithubToken(): Option<string>
|
||||
return Option.from(process.env.GITHUB_TOKEN):orElse(function()
|
||||
return ResultExt.ok(Result.try(process.spawn, "gh", { "auth", "token" }))
|
||||
:andThen(function(child: process.SpawnResult)
|
||||
return ResultExt.ok(Result.try(process.exec, "gh", { "auth", "token" }))
|
||||
:andThen(function(child: process.ExecResult)
|
||||
if not child.ok then
|
||||
return Option.None
|
||||
end
|
||||
|
|
|
@ -36,9 +36,9 @@ function sys.isTTY(fd: number | StdioFd): boolean
|
|||
local pid = assert(string.match(statFd, "^%S+%s+%S+%s+%S+%s+(%S+)"), "Could not get current process PID")
|
||||
|
||||
local stdoutFdMode = ResultExt.ok(
|
||||
Result.try(process.spawn, "stat", { "-L", "-c", "%f", `/proc/{pid}/fd/{inputFd}` })
|
||||
Result.try(process.exec, "stat", { "-L", "-c", "%f", `/proc/{pid}/fd/{inputFd}` })
|
||||
)
|
||||
:andThen(function(child: process.SpawnResult)
|
||||
:andThen(function(child: process.ExecResult)
|
||||
if not child.ok then
|
||||
return Option.None
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue