Fixes linter/build errors from editing last night in GitHub

This commit is contained in:
RevanProdigalKnight 2022-05-04 08:27:52 -06:00
parent df30771744
commit 8d5f80de26

@ -1,17 +1,17 @@
import { KEY } from "../utils/helpers/keyCodes"; import { KEY } from "../utils/helpers/keyCodes";
import { substituteAliases } from "../Alias"; import { substituteAliases } from "../Alias";
// Helper function to parse individual arguments into number/boolean/string as appropriate // Helper function to parse individual arguments into number/boolean/string as appropriate
function parseArg(arg) { function parseArg(arg: string): string | number | boolean {
// Handles all numbers including hexadecimal, octal, and binary representations, returning NaN on an unparseable string // Handles all numbers including hexadecimal, octal, and binary representations, returning NaN on an unparseable string
const asNumber = Number(arg); const asNumber = Number(arg);
if (!isNaN(asNumber)) { if (!isNaN(asNumber)) {
return asNumber; return asNumber;
} }
if (arg === 'true' || arg === 'false') { if (arg === 'true' || arg === 'false') {
return arg === 'true'; return arg === 'true';
} }
// Strip quotation marks from strings that begin/end with the same mark // Strip quotation marks from strings that begin/end with the same mark
return arg.replace(/^"(.*?)"$/g, '$1').replace(/^'(.*?)'$/g, '$1'); return arg.replace(/^"(.*?)"$/g, '$1').replace(/^'(.*?)'$/g, '$1');
} }
@ -44,14 +44,14 @@ export function ParseCommands(commands: string): string[] {
export function ParseCommand(command: string): (string | number | boolean)[] { export function ParseCommand(command: string): (string | number | boolean)[] {
let idx = 0; let idx = 0;
const args = []; const args = [];
// Track depth of quoted strings, e.g.: "the're 'going away' rather 'quickly \"and awkwardly\"'" should be parsed as a single string // Track depth of quoted strings, e.g.: "the're 'going away' rather 'quickly \"and awkwardly\"'" should be parsed as a single string
const quotes = []; const quotes: string[] = [];
let arg = ''; let arg = '';
while (idx < command.length) { while (idx < command.length) {
const c = command.charAt(idx); const c = command.charAt(idx);
// If the current character is a backslash, add the next character verbatim to the argument // If the current character is a backslash, add the next character verbatim to the argument
if (c === '\\') { if (c === '\\') {
arg += command.charAt(++idx); arg += command.charAt(++idx);
@ -89,20 +89,20 @@ export function ParseCommand(command: string): (string | number | boolean)[] {
// and start a new one // and start a new one
} else if (c === KEY.SPACE && quotes.length === 0) { } else if (c === KEY.SPACE && quotes.length === 0) {
args.push(parseArg(arg)); args.push(parseArg(arg));
arg = ''; arg = '';
} else { } else {
// Add the current character to the current argument // Add the current character to the current argument
arg += c; arg += c;
} }
idx++; idx++;
} }
// Add the last arg (if any) // Add the last arg (if any)
if (arg !== '') { if (arg !== '') {
args.push(parseArg(arg)); args.push(parseArg(arg));
} }
return args; return args;
} }