Skip to content

Commit

Permalink
Support to config js args
Browse files Browse the repository at this point in the history
  • Loading branch information
chinesedfan authored and agrawal-d committed Nov 22, 2023
1 parent 31e6018 commit 608aa2d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
11 changes: 7 additions & 4 deletions src/preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(' ') || [];

Expand Down Expand Up @@ -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';

Expand All @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
7 changes: 4 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -85,8 +86,8 @@ export const getLanguage = (srcPath: string): Language => {
case 'js': {
return {
name: langName,
args: [],
compiler: getJavaScriptCommand(),
args: [...getJsArgsPref()],
compiler: getJsCommand(),
skipCompile: true,
};
}
Expand Down

0 comments on commit 608aa2d

Please sign in to comment.