Prevent errors thrown from terminal (#443)

At least from getFilepath function
This commit is contained in:
Snarling
2023-03-23 12:01:58 -04:00
committed by GitHub
parent 07b18edb5c
commit 6290ce562a
13 changed files with 44 additions and 77 deletions
+2
View File
@@ -109,6 +109,7 @@ export function commonEditor(
if (isScriptFilename(filename)) {
const filepath = Terminal.getFilepath(filename);
if (!filepath) throw `Invalid filename: ${filename}`;
const script = Terminal.getScript(filename);
const fileIsNs2 = isNs2(filename);
const code = script !== null ? script.code : fileIsNs2 ? newNs2Template : "";
@@ -125,6 +126,7 @@ export function commonEditor(
if (filename.endsWith(".txt")) {
const filepath = Terminal.getFilepath(filename);
if (!filepath) throw `Invalid filename: ${filename}`;
const txt = Terminal.getTextFile(filename);
return [filepath, txt === null ? "" : txt.text];
}