Skip to content

Commit

Permalink
Fix #164: Make temporary file name not random by default; Support run…
Browse files Browse the repository at this point in the history
…ning code snippet in terminal
  • Loading branch information
formulahendry committed Aug 20, 2017
1 parent 25100f2 commit 737ab48
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.DS_Store
npm-debug.log
out
node_modules
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 0.7.0 (2017-08-20)
* [#164](https://github.com/formulahendry/vscode-code-runner/issues/164): Make temporary file name not random by default
* Support running code snippet in terminal

### 0.6.33 (2017-08-10)
* [#149](https://github.com/formulahendry/vscode-code-runner/issues/149): Set custom terminal root path for Linux Shell on Windows

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ To set whether to preserve focus on code editor after code run is triggered (def

`code-runner.terminalRoot`: For Windows system, replaces the Windows style drive letter in the command with a Unix style root when using a custom shell as the terminal, like Bash or Cgywin. Example: Setting this to `/mnt/` will replace `C:\path` with `/mnt/c/path` (Default is **""**)

`code-runner.temporaryFileName`: Temporary file name used in running selected code snippet. When it is set as empty, the file name will be random. (Default is **"tempCodeRunnerFile"**)

## About CWD Setting (current working directory)
1. By default, use the `code-runner.cwd` setting
2. If `code-runner.cwd` is not set and `code-runner.fileDirectoryAsCwd` is `true`, use the directory of the file to be executed
Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "code-runner",
"displayName": "Code Runner",
"description": "Run C, C++, Java, JS, PHP, Python, Perl, Ruby, Go, Lua, Groovy, PowerShell, CMD, BASH, F#, C#, VBScript, TypeScript, CoffeeScript, Scala, Swift, Julia, Crystal, OCaml, R, AppleScript, Elixir, VB.NET, Clojure, Haxe, Objective-C, Rust, Racket, AutoHotkey, AutoIt, Kotlin, Dart, Pascal, Haskell, Nim, D",
"version": "0.6.33",
"version": "0.7.0",
"publisher": "formulahendry",
"icon": "images/logo.png",
"engines": {
Expand Down Expand Up @@ -247,6 +247,11 @@
"type": "boolean",
"default": true,
"description": "Whether to show 'Run Code' icon in editor title menu."
},
"code-runner.temporaryFileName": {
"type": "string",
"default": "tempCodeRunnerFile",
"description": "Temporary file name used in running selected code snippet. When it is set as empty, the file name will be random."
}
}
},
Expand Down
6 changes: 4 additions & 2 deletions src/codeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ export class CodeManager {
fileType = "." + this._languageId;
}
}
const tmpFileName = "temp" + this.rndName() + fileType;
const temporaryFileName = this._config.get<string>("temporaryFileName");
const tmpFileNameWithoutExt = temporaryFileName ? temporaryFileName : "temp" + this.rndName();
const tmpFileName = tmpFileNameWithoutExt + fileType;
this._codeFile = join(folder, tmpFileName);
fs.writeFileSync(this._codeFile, content);
}
Expand Down Expand Up @@ -200,7 +202,7 @@ export class CodeManager {
}

private executeCommand(executor: string, appendFile: boolean = true) {
if (this._config.get<boolean>("runInTerminal") && !this._isTmpFile) {
if (this._config.get<boolean>("runInTerminal")) {
this.executeCommandInTerminal(executor, appendFile);
} else {
this.executeCommandInOutputChannel(executor, appendFile);
Expand Down

0 comments on commit 737ab48

Please sign in to comment.