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)) {
|
if (/up to date/.test(out)) {
|
||||||
return "Up to date."
|
return "Up to date."
|
||||||
} else {
|
} else {
|
||||||
setTimeout(() => process.exit(), 1000)
|
setTimeout(() => process.exit(), 500)
|
||||||
return "Restarting in 1 second..."
|
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
|
html = true
|
||||||
content = output.html
|
content = output.html
|
||||||
if (output.script) eval(output.script)
|
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) {
|
} else if ("script" in output) {
|
||||||
eval(output.script)
|
eval(output.script!)
|
||||||
} else {
|
} else {
|
||||||
content = JSON.stringify(output)
|
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"
|
| "stream:start" | "stream:end" | "stream:append" | "stream:replace"
|
||||||
|
|
||||||
export type CommandOutput = string | string[]
|
export type CommandOutput = string | string[]
|
||||||
| { html: string, script?: string } | { script: string }
|
| { text: string, script?: string }
|
||||||
|
| { html: string, script?: string }
|
||||||
|
| { script: string }
|
||||||
| { game: string }
|
| { game: string }
|
||||||
|
|
||||||
export type CommandResult = {
|
export type CommandResult = {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user