Skip to content

Commit

Permalink
Resolve #54: Add support for VB.NET; Resolve #51: Add support for $wo…
Browse files Browse the repository at this point in the history
…rkspaceRoot
  • Loading branch information
formulahendry committed Jan 20, 2017
1 parent 0b0f646 commit 6b1c0ca
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 0.6.6
* Resolve [GitHub issue#54](https://github.com/formulahendry/vscode-code-runner/issues/54): Add support for VB.NET
* Resolve [GitHub issue#51](https://github.com/formulahendry/vscode-code-runner/issues/51): Add support for $workspaceRoot

### 0.6.5
* Resolve [GitHub issue#43](https://github.com/formulahendry/vscode-code-runner/issues/43): Add support for Elixir
* Upgrade applicationinsights npm since [telemetry data requires HTTPS](https://azure.microsoft.com/en-us/updates/application-insights-telemetry-data-now-requires-https-with-shutdown-of-http-data-collectors/)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Join the chat at https://gitter.im/formulahendry/vscode-code-runner](https://badges.gitter.im/formulahendry/vscode-code-runner.svg)](https://gitter.im/formulahendry/vscode-code-runner?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Marketplace Version](http://vsmarketplacebadge.apphb.com/version/formulahendry.code-runner.svg)](https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner) [![Installs](http://vsmarketplacebadge.apphb.com/installs/formulahendry.code-runner.svg)](https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner) [![Rating](http://vsmarketplacebadge.apphb.com/rating/formulahendry.code-runner.svg)](https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner) [![Build Status](https://travis-ci.org/formulahendry/vscode-code-runner.svg?branch=master)](https://travis-ci.org/formulahendry/vscode-code-runner)

Run code snippet or code file for multiple languages: **C, C++, Java, JavaScript, PHP, Python, Perl, Ruby, Go, Lua, Groovy, PowerShell, BAT/CMD, BASH/SH, F# Script, C# Script, VBScript, TypeScript, CoffeeScript, Scala, Swift, Julia, Crystal, OCaml Script, R, AppleScript, Elixir**, and custom command
Run code snippet or code file for multiple languages: **C, C++, Java, JavaScript, PHP, Python, Perl, Ruby, Go, Lua, Groovy, PowerShell, BAT/CMD, BASH/SH, F# Script, C# Script, VBScript, TypeScript, CoffeeScript, Scala, Swift, Julia, Crystal, OCaml Script, R, AppleScript, Elixir, Visual Basic .NET**, and custom command

## Features

Expand Down Expand Up @@ -49,6 +49,7 @@ e.g. To set the executor PATH for ruby, php and html:
}
```
**Supported customized parameters**
* $workspaceRoot: The path of the folder opened in VS Code
* $dir: The directory of the code file being run
* $fullFileName: The full name of the code file being run
* $fileName: The base name of the code file being run, that is the file without the directory
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "code-runner",
"displayName": "Code Runner",
"description": "Run code snippet/file for C, C++, Java, JS, PHP, Python, Perl, Ruby, Go, Lua, Groovy, PowerShell, BAT/CMD, BASH/SH, F#, C#, VBScript, TypeScript, CoffeeScript, Scala, Swift, Julia, Crystal, OCaml, R, AppleScript, Elixir",
"version": "0.6.5",
"description": "Run code snippet/file for C, C++, Java, JS, PHP, Python, Perl, Ruby, Go, Lua, Groovy, PowerShell, BAT/CMD, BASH/SH, F#, C#, VBScript, TypeScript, CoffeeScript, Scala, Swift, Julia, Crystal, OCaml, R, AppleScript, Elixir, VB.NET",
"version": "0.6.6",
"publisher": "formulahendry",
"icon": "images/logo.png",
"engines": {
Expand Down Expand Up @@ -124,6 +124,7 @@
"code-runner.executorMapByFileExtension": {
"type": "object",
"default": {
".vb": "cd $dir && vbc /nologo $fileName && $fileNameWithoutExt",
".vbs": "cscript //Nologo",
".scala": "scala",
".jl": "julia",
Expand Down
12 changes: 10 additions & 2 deletions src/codeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ export class CodeManager {
}
}

private getWorkspaceRoot(codeFileDir: string): string {
return vscode.workspace.rootPath ? vscode.workspace.rootPath : codeFileDir;
}

/**
* Gets the base name of the code file, that is without its directory.
*/
Expand Down Expand Up @@ -245,15 +249,19 @@ export class CodeManager {
var cmd = executor

if (this._codeFile) {
var placeholders: { regex: RegExp, replaceValue: string }[] = [
let codeFileDir = this.getCodeFileDir();
let placeholders: { regex: RegExp, replaceValue: string }[] = [
//A placeholder that has to be replaced by the path of the folder opened in VS Code
//If no folder is opened, replace with the directory of the code file
{ "regex": /\$workspaceRoot/g, "replaceValue": this.getWorkspaceRoot(codeFileDir) },
//A placeholder that has to be replaced by the code file name without its extension
{ "regex": /\$fileNameWithoutExt/g, "replaceValue": this.getCodeFileWithoutDirAndExt() },
//A placeholder that has to be replaced by the full code file name
{ "regex": /\$fullFileName/g, "replaceValue": this.quoteFileName(this._codeFile) },
//A placeholder that has to be replaced by the code file name without the directory
{ "regex": /\$fileName/g, "replaceValue": this.getCodeBaseFile() },
//A placeholder that has to be replaced by the directory of the code file
{ "regex": /\$dir/g, "replaceValue": this.quoteFileName(this.getCodeFileDir()) }
{ "regex": /\$dir/g, "replaceValue": this.quoteFileName(codeFileDir) }
];

placeholders.forEach(placeholder => {
Expand Down

0 comments on commit 6b1c0ca

Please sign in to comment.