From 608aa2d90ebe2961497142a08d8f0bd4a6a4e8e9 Mon Sep 17 00:00:00 2001 From: Xianming Zhong Date: Wed, 22 Nov 2023 10:17:15 +0800 Subject: [PATCH] Support to config js args --- package.json | 12 +++++++++--- src/preferences.ts | 11 +++++++---- src/types.ts | 5 +++-- src/utils.ts | 7 ++++--- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 9b2663f..cfa9ee7 100644 --- a/package.json +++ b/package.json @@ -210,15 +210,21 @@ "default": "javac", "description": "Command used to compile java files." }, - "cph.language.javascript.SubmissionCompiler": { + "cph.language.js.Args": { + "title": "Compilation flags for JavaScript", + "type": "string", + "default": "", + "description": "Space seperated additional flags passed to node (for JavaScript) while compiling your file. Example '--abort-on-uncaught-exception'" + }, + "cph.language.js.SubmissionCompiler": { "type": "string", "default": "Node.js 15.8.0 (64bit)", "enum": [ "Node.js 15.8.0 (64bit)" ], - "description": "The compiler chosen in the drop down during Codeforces submission for Node.js" + "description": "The compiler chosen in the drop down during Codeforces submission for js" }, - "cph.language.javascript.Command": { + "cph.language.js.Command": { "type": "string", "default": "node", "description": "Command used to compile .js files." diff --git a/src/preferences.ts b/src/preferences.ts index cd23758..df1bee4 100644 --- a/src/preferences.ts +++ b/src/preferences.ts @@ -59,6 +59,9 @@ export const getRustArgsPref = (): string[] => export const getJavaArgsPref = (): string[] => getPreference('language.java.Args').split(' ') || []; +export const getJsArgsPref = (): string[] => + getPreference('language.js.Args').split(' ') || []; + export const getGoArgsPref = (): string[] => getPreference('language.go.Args').split(' ') || []; @@ -94,8 +97,8 @@ export const getRustCommand = (): string => getPreference('language.rust.Command') || 'rustc'; export const getJavaCommand = (): string => getPreference('language.java.Command') || 'javac'; -export const getJavaScriptCommand = (): string => - getPreference('language.javascript.Command') || 'node'; +export const getJsCommand = (): string => + getPreference('language.js.Command') || 'node'; export const getGoCommand = (): string => getPreference('language.go.Command') || 'go'; @@ -116,9 +119,9 @@ export const getLanguageId = (srcPath: string): number => { compiler = getPreference('language.java.SubmissionCompiler'); break; } - + case '.js': { - compiler = getPreference('language.javascript.SubmissionCompiler'); + compiler = getPreference('language.js.SubmissionCompiler'); break; } diff --git a/src/types.ts b/src/types.ts index 55e10c3..5552935 100644 --- a/src/types.ts +++ b/src/types.ts @@ -23,8 +23,9 @@ export type prefSection = | 'language.java.Args' | 'language.java.SubmissionCompiler' | 'language.java.Command' - | 'language.javascript.SubmissionCompiler' - | 'language.javascript.Command' + | 'language.js.Args' + | 'language.js.SubmissionCompiler' + | 'language.js.Command' | 'language.python.Args' | 'language.python.SubmissionCompiler' | 'language.python.Command' diff --git a/src/utils.ts b/src/utils.ts index 4b92b05..15d2738 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -12,13 +12,14 @@ import { getPythonArgsPref, getRustArgsPref, getJavaArgsPref, + getJsArgsPref, getGoArgsPref, getCCommand, getCppCommand, getPythonCommand, getRustCommand, getJavaCommand, - getJavaScriptCommand, + getJsCommand, getGoCommand, } from './preferences'; import { Language, Problem } from './types'; @@ -85,8 +86,8 @@ export const getLanguage = (srcPath: string): Language => { case 'js': { return { name: langName, - args: [], - compiler: getJavaScriptCommand(), + args: [...getJsArgsPref()], + compiler: getJsCommand(), skipCompile: true, }; }