diff options
author | Zachary Zhang <zacharyzhang7@gmail.com> | 2024-04-02 16:37:22 -0400 |
---|---|---|
committer | Zachary Zhang <zacharyzhang7@gmail.com> | 2024-04-02 16:37:22 -0400 |
commit | 427406dc60f0f037d69e0992fbb3205476daf89e (patch) | |
tree | b19538c66ade34ab4d2684589dbb8604a613e7ff /src/client/util/Scripting.ts | |
parent | dc0ee4595e37042db3adf60b002d7baf77cb24ae (diff) | |
parent | 3d158bb9b941a3fcb1b486f354ca5c9195dd21c2 (diff) |
Merge branch 'master' into zach-starter
Diffstat (limited to 'src/client/util/Scripting.ts')
-rw-r--r-- | src/client/util/Scripting.ts | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/client/util/Scripting.ts b/src/client/util/Scripting.ts index f5e162d16..422e708bc 100644 --- a/src/client/util/Scripting.ts +++ b/src/client/util/Scripting.ts @@ -88,15 +88,10 @@ function Run(script: string | undefined, customParams: string[], diagnostics: an } const result = compiledFunction.apply(thisParam, params).apply(thisParam, argsArray); - if (batch) { - batch.end(); - } - + batch?.end(); return { success: true, result }; } catch (error) { - if (batch) { - batch.end(); - } + batch?.end(); onError?.(script + ' ' + error); return { success: false, error, result: errorVal }; } @@ -255,7 +250,7 @@ export function CompileScript(script: string, options: ScriptOptions = {}): Comp const outputText = host.readFile('file.js'); const diagnostics = ts.getPreEmitDiagnostics(program).concat(testResult.diagnostics); - + if (script.startsWith('@')) options.typecheck = true; // need the compilation to fail so that the script will return itself as a string (instead of nothing) const result = Run(outputText, paramNames, diagnostics, script, options); if (options.globals) { |