46 lines
1.2 KiB
Text
46 lines
1.2 KiB
Text
--!strict
|
|
local process = require("@lune/process")
|
|
local stdio = require("@lune/stdio")
|
|
|
|
local result = require("@pkg/result")
|
|
|
|
local function c_print(msg: string)
|
|
stdio.write(`{stdio.color("blue")}[info]{stdio.color("reset")} {msg}\n`)
|
|
end
|
|
|
|
local function c_warn(msg: string)
|
|
stdio.write(`{stdio.color("yellow")}[warn]{stdio.color("reset")} {msg}\n`)
|
|
end
|
|
|
|
local function c_error(msg: string)
|
|
stdio.ewrite(`{stdio.color("red")}[error]{stdio.color("reset")} {msg}\n`)
|
|
end
|
|
|
|
local function c_spawn(command: string): result.Identity<process.SpawnResult>
|
|
local args = string.split(command, " ")
|
|
local program = table.remove(args, 1)
|
|
if not program then
|
|
return result(false, "Couldn't find program in command.")
|
|
end
|
|
|
|
local spawn_result = process.spawn(program, args)
|
|
if not spawn_result.ok then
|
|
return result(false, spawn_result.stderr)
|
|
end
|
|
|
|
return result(true, spawn_result)
|
|
end
|
|
|
|
local common = {
|
|
default_name = "CSSharpTemplate",
|
|
|
|
print = c_print,
|
|
warn = c_warn,
|
|
error = c_error,
|
|
|
|
spawn = c_spawn,
|
|
}
|
|
|
|
export type Replicator = (dist_folder: string, remote_output: string) -> result.Identity<nil>
|
|
|
|
return common
|