Expand hot reload into function
This commit is contained in:
parent
41d2330f28
commit
6a21aa0cbd
28
src/index.ts
28
src/index.ts
|
@ -23,23 +23,27 @@ function load() {
|
||||||
globalThis.loaded = true;
|
globalThis.loaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for hot reload
|
function reload() {
|
||||||
if (!globalThis.loaded) {
|
console.log("Reloading...");
|
||||||
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();
|
|
||||||
});
|
|
||||||
|
|
||||||
// Reload commands
|
// Reload commands
|
||||||
globalThis.commandHandler.commandGroups = new Array<CommandGroup>();
|
globalThis.commandHandler.commandGroups = new Array<CommandGroup>();
|
||||||
loadCommands();
|
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) {
|
export function scopedEval(code: string) {
|
||||||
|
|
Loading…
Reference in New Issue