Expand hot reload into function

This commit is contained in:
Hri7566 2023-12-16 18:37:21 -05:00
parent 41d2330f28
commit 6a21aa0cbd
1 changed files with 16 additions and 12 deletions

View File

@ -23,23 +23,27 @@ function load() {
globalThis.loaded = true;
}
// Check for hot reload
if (!globalThis.loaded) {
load();
console.log("Command list:", globalThis.commandHandler.commandGroups);
} else {
console.log("Hot reload triggered...");
// Set console prompt
globalThis.serviceLoader.agents.forEach(agent => {
if (agent.platform === "console")
(agent as ConsoleAgent).client.prompt();
});
function reload() {
console.log("Reloading...");
// Reload commands
globalThis.commandHandler.commandGroups = new Array<CommandGroup>();
loadCommands();
console.log("Command list:", globalThis.commandHandler.commandGroups);
// Set console prompt
globalThis.serviceLoader.agents.forEach(agent => {
if (agent.platform === "console")
(agent as ConsoleAgent).client.prompt();
});
}
// Check for hot reload
if (!globalThis.loaded) {
load();
} else {
console.clear();
console.log("Hot reload triggered");
reload();
}
export function scopedEval(code: string) {