Skip to content

Commit

Permalink
Resolve #11: Set the mapping of languageId to file extension
Browse files Browse the repository at this point in the history
  • Loading branch information
formulahendry committed Aug 14, 2016
1 parent 5a42d5e commit 911ddb6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@
},
"description": "Set the executor of each file extension."
},
"code-runner.languageIdToFileExtensionMap": {
"type": "object",
"default": {
"bat": ".bat",
"powershell": ".ps1"
},
"description": "Set the mapping of languageId to file extension."
},
"code-runner.defaultLanguage": {
"type": "string",
"default": "",
Expand Down
7 changes: 4 additions & 3 deletions src/codeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export class CodeManager {

this._isTmpFile = true;
let folder = editor.document.isUntitled ? this._cwd : dirname(editor.document.fileName);
this.createRandomFile(text, folder, fileExtension);
this.createRandomFile(text, folder, fileExtension);
}

this.executeCommand(executor);
Expand All @@ -110,8 +110,9 @@ export class CodeManager {

private createRandomFile(content: string, folder: string, fileExtension: string) {
let fileType = "";
if (this._languageId === 'bat') {
fileType = '.bat';
let languageIdToFileExtensionMap = this._config.get<any>('languageIdToFileExtensionMap');
if (languageIdToFileExtensionMap[this._languageId]) {
fileType = languageIdToFileExtensionMap[this._languageId];
} else {
if (fileExtension) {
fileType = fileExtension;
Expand Down

0 comments on commit 911ddb6

Please sign in to comment.