aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/Scripting.ts
diff options
context:
space:
mode:
authoraidahosa1 <aisosa_idahosa@brown.edu>2024-05-07 17:37:36 -0400
committeraidahosa1 <aisosa_idahosa@brown.edu>2024-05-07 17:37:36 -0400
commit4788b30975a996d1860b8978f482973fdcc920fe (patch)
treed4f245f0cbbe18c63c19f77b49a77e822a0cbbc6 /src/client/util/Scripting.ts
parent8ca77556c3a9caba66faf37fbf259762c2084c0b (diff)
parent2caf7b7bb80b663b6ba585f88cdbd2d725f8505e (diff)
Merge branch 'master' into aisosa-starter
Diffstat (limited to 'src/client/util/Scripting.ts')
-rw-r--r--src/client/util/Scripting.ts11
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) {