run scripts from the backend
This commit is contained in:
parent
a6bdd6bb29
commit
da28a739df
|
|
@ -13,7 +13,10 @@ export default async function () {
|
|||
if (/up to date/.test(out)) {
|
||||
return "Up to date."
|
||||
} else {
|
||||
setTimeout(() => process.exit(), 1000)
|
||||
return "Restarting in 1 second..."
|
||||
setTimeout(() => process.exit(), 500)
|
||||
return {
|
||||
text: "Reloading in 3 seconds...",
|
||||
script: `setTimeout(() => (window as any).location = window.location, 3000)`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -124,8 +124,11 @@ function processOutput(output: CommandOutput): ["html" | "text", string] {
|
|||
html = true
|
||||
content = output.html
|
||||
if (output.script) eval(output.script)
|
||||
} else if ("text" in output) {
|
||||
content = output.text
|
||||
if (output.script) eval(output.script)
|
||||
} else if ("script" in output) {
|
||||
eval(output.script)
|
||||
eval(output.script!)
|
||||
} else {
|
||||
content = JSON.stringify(output)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@ export type MessageType = "error" | "input" | "output" | "commands" | "save-file
|
|||
| "stream:start" | "stream:end" | "stream:append" | "stream:replace"
|
||||
|
||||
export type CommandOutput = string | string[]
|
||||
| { html: string, script?: string } | { script: string }
|
||||
| { text: string, script?: string }
|
||||
| { html: string, script?: string }
|
||||
| { script: string }
|
||||
| { game: string }
|
||||
|
||||
export type CommandResult = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user