Coder Social home page Coder Social logo

formulahendry / vscode-code-runner Goto Github PK

View Code? Open in Web Editor NEW
2.1K 35.0 282.0 1.22 MB

Code Runner for Visual Studio Code

Home Page: https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner

License: MIT License

TypeScript 100.00%
vscode typescript runner executor visual-studio-code vscode-extension

vscode-code-runner's Issues

Wrong node version referenced

Hi, great extensions, thanks.

I use nvm to manage a multi-version node environment.

The problem is like below:

  1. Start VSC, (node version = 4.7)
  2. in the integrated terminal, which has the following settings in the user settings
//to enable running bash as a login shell (which runs `.bash_profile`)
"terminal.integrated.shellArgs.osx": [
        "-l"
    ],
  1. Run the command, "nvm use 6", now the node version changes to 6
  2. Executing console.log(process.version), the output is v4.7.0
  3. In the integrated terminal, executing the file by node test.js, the output is v6.9.2
  4. nvm will add the following lines to the .bash_profile:
export NVM_DIR="/Users/albertgao/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm
  1. but seems I don't know how to add it to the "code-runner.executorMap": {}

It would be super nice if the code-runner could use the interpreter which comes from the integrated terminal or at least we can configure it :) Thanks.

Add VBScript support

Add the ability to run VBScript directly from the VS Code.

I'm not sure if this is something you want to add since there are workarounds, such as customizing the user's 'settings.json' to add the language.

Add Support for Ocaml

I'm using vs code with the ocaml extension , and it has been a joy .
Please can you add support for running ocaml code too , it would be fantastic for the ocaml users of vs code

${workspaceRoot} support

In the setting file, how to enter the workspaceRoot directory? such as "cpp": "cd $workspaceRoot && build && out.exe".

Auto output

I use a lot the code runner in javascript to play with other libraries or to create a spike for a function and usually I end up filling my snippets with console.log to get the output.
Probably it would be useful that the extension automatically prints to the console the result of the evaluation.
The ramda playground is a good example: http://ramdajs.com/repl/
Opinions?

Thx

[REQUEST] VisualBasic.NET Support

Since this extension can support C# and managed C++ (VC++) languages, and we know that VB.NET is also "natively" supported in VS Code as part of the .NET platform like the two other mentioned languages, then I would like to ask why this extension ddn't added support VB.NET, and if it is going to add support for that language in the near future (I imagine it only would require little modifications).

Thanks for read.

ABOUT SET PYTHON PATH

i set the path of python like this:
"code-runner.executorMap": {
"python": "C:\Program Files\Python35\python.exe"
}
but run faid:
[Running] C:\Program Files\Python35\python.exe "c:\Users\Administrator\Desktop\中文\temp-fuopntmsyc.py"
'C:\Program' �����ڲ����ⲿ���Ҳ���ǿ����еij���
���������ļ���

[Done] exited with code=1 in 0.045 seconds

what can i do ,thank you!

Error with scriptcs

Hi @formulahendry

As mentioned in the readme I've installed the scriptcs extension and it works fine on the terminal for the *.csx scripts but it's not the same with run code command in VsCode.

Console.WriteLine("Hello C#")

The above displays the expected output with scriptcs scratch.csx but inside VsCode it raises the following error

[Running] scriptcs "/Users/eklavya/Projects/Amsterdam/RosettaCode/scratch.csx"
Unexpected named argument: Users/eklavya/Projects/Amsterdam/RosettaCode/scratch.csx
Usage: scriptcs options

   OPTION                    DESCRIPTION                                                                                     
   -ScriptName (-script)     Script file name, must be specified first                                                       
   -Repl (-R)                Launch REPL mode when running script. To just launch REPL, simply omit the 'script' argument.   
   -Help (-?)                Displays help                                                                                   
   -Debug (-D)               Emits PDB symbols allowing for attaching a Visual Studio debugger                               
   -Cache (-C)               Flag which determines whether to run in memory or from a .dll                                   
   -LogLevel (-log)          Flag which defines the log level used.                                                          
   -Install (-i)             Installs and restores packages which are specified in packages.config                           
   -Global (-g)              Installs and restores global packages which are specified in packages.config                    
   -Save (-S)                Creates a packages.config file based on the packages directory                                  
   -Clean (-Cl)              Cleans installed packages from working directory                                                
   -AllowPreRelease (-pre)   Allows installation of packages' prelease versions                                              
   -Version (-V)             Outputs version information                                                                     
   -Watch (-W)               Watch the script file and reload it when changed                                                
   -Modules (-M)             Specify modules to load                                                                         
   -Config (-Co)             Defines config file name                                                                        
   -PackageVersion (-P)      Defines the version of the package to install. Used in conjunction with -install                
   -Output (-O)              Write all console output to the specified file                                                  

   EXAMPLE: scriptcs server.csx -logLevel debug
   Executes the 'server.csx' script and displays detailed log messages. Useful for debugging.



[Done] exited with code=1 in 0.302 seconds

option to save the file before running

So if you have autosave on (on "onFocusChange") it does not consider changing the focus when running the script with this extension (which I believe is the expected behavior since every time I'd like to run a script I would need to change the focus back to the file to keep working on it).

But if you have autosave on, you would expect the file to be saved before running it. So could the extension have an option to save the file before running it? :)

Please add debug support

I just tried add it at pull requests instead issues but no text field open to me can write it.

But, if possible, add support to debug programs.
I would like to have it at least for Groovy, Swift, Java, Ruby and C#.
VB.Net support would be nice too.

Thanks.

"Run Code" in Output console

Currently context menu of Output panel has "Run Code" menu, which return "Code language not supported or defined."

Is it bug or a feature?

cwd

When running, for example, a js (node) script, it sets the cwd to the global node installation so any modules you have locally installed won't recognize and err...

code-runner.cwd support variables

Can you add support variables like ${fileDirname} for "Set the working directory" setting?
I need exec scripts from local directory.

thank you.

Opening html in browser (or, using any command)

Hi, thanks the very neat extension.

I tried to configure the Code Runner to open html files in Chrome, but not working.

Config:

"code-runner.executorMap": {
    "javascript": "node"
},
"code-runner.defaultLanguage": "javascript",
"code-runner.clearPreviousOutput": true,
"code-runner.saveFileBeforeRun": false,
"code-runner.executorMapByFileExtension": {
    ".html": "chrome.exe"
}

But I m getting below error:

[Running] chrome.exe "d:\angular-directive-demo.html"
'chrome.exe' is not recognized as an internal or external command,
operable program or batch file.

[Done] exited with code=1 in 0.176 seconds

I tried given the chrome.exe's complete path as well, but same issue.

Is there any way to invoke any arbitrary command/exe?

Code Runner: 0.4.1
VSCode: 1.7.1
Windows 8.1

Thanks.

Why show the error "prompt is not defined"?

Dear guys:
I use Visual Studio Code recently, and I found something strange today. When I use the plugin named "Code Runner" to test my code which involves the function "prompt()", the terminal always show the error "prompt is not defined". (Please refer the code)

var names = ["David", "Cynthia", "Raymond", "Clayton", "Jennifer"];
var name = prompt();
var position = names.indexOf(name);
if (position >= 0) {
console.log("Found at position " + position);
} else {
console.log("not found in array.");
}

Please help me to figure out the reason and to find out how to replace "prompt()" by other function?

Thank you so much!

gibberish happened

When I run typescript file,gibberish happened.I juest write one line code,"console.info("jike");",so as follows:

[Running] ts-node "f:\vscodeSpace\typingsTest\app.ts"
'ts-node' �����ڲ����ⲿ���Ҳ���ǿ����еij���
���������ļ���

Can we work with transpiled sources?

Lets say I'm looking at a es6 script and I have the Babel watch task open to transpile my code to a "build" directory in the root of my project. How would I use this extension in such a scenario?

A few ideas

Hi, would it be possible to add a 'run code' option under the File menu? Also I think it would be nice if you choose to open a new window and see the results there.
Thank you!

output panels reuse

EDIT: this issue is irrelevant and don't belong in this repo. Apologies

The runner creates an output panel every time its goes, should it reuse only one?

Define default language for code execution

Is it possible to define default language for code execution?

For example I open new plain text file (Ctrl+N) and do some javascript in it and want to run it but it says 'Code language not supported or defined'.

Can I set to run code as javascript if code language is not defined?

For fast code testing without saving new file it would be even better to have commands like 'run code js', 'run code php' and so on.

set env variable before excuting python file

First of all,thanks for your ext! It's really awesome
on windows
the default encoding of cmd is cp936,but the this ext output default is utf8 that will case a decoding problem,
like this:
image

i wonder if it's better to add a feature for some language to set the environment variable before executing *.py file

like the task.json
image

multiple executor map entries

Hi,

please add an option to configure multiple commands for filetypes:

this would be usefull if you need to execute your code in different environments.

Examples:

  • running bash script on local machine or remote server
  • running sql scripts on different databases (sqlplus, mysql, psql )
  • compiling for production or debug
  • use different versions of a tool

If you have multiple tools configured, the code runner will ask you wich tool you want to use.

You should be able to configure the order, in which the tools will be listed.
(priority config, alphabetical or recently used)

Configuration example:
{ "code-runner.executorMap": { "bash": { "local" : "bash", "remote" : "ssh" }, "sql": { "mysql" : "mysql", "oracle" : "sqlplus", "postgreSQL" : "psql" }, } }

能否加入对TestNG的支持

通常在工作目录下执行

mvn test -Dtest=com.test.api.testcase#case1

即可运行一个测试case

希望run code可以加入此类文件的执行

usage with nodemon

I want to do nodemon somefile.js (nodemon installed locally so I need to go through the npm script).

so in scripts in package.json I have

"mon": "nodemon",

and in code-runner execmap settings:
"mon": "npm run mon",

I get this:

> [email protected] mon c:\Users\rickm\Documents\Google Drive\Side-projects\Programming\NodeJS\playground-js
> nodemon "c:\Users\rickm\Documents\Google Drive\Side-projects\Programming\NodeJS\playground-js\server_frameworks\spirit\return-early.js"

[nodemon] 1.10.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node "c:\\Users\\rickm\\Documents\\Google Drive\\Side-projects\\Programming\\NodeJS\\playground-js\\server_frameworks\\spirit\\return-early.js"`
module.js:442
    throw err;
    ^

Error: Cannot find module 'c:\Users\rickm\Documents\Google Drive\Side-projects\Programming\NodeJS\playground-js\"c:\Users\rickm\Documents\Google'

Javascript module reference

Is there an obvious way to run this JavaScript snippet?
--- js code ---
require('moment')
console.log('--- start')
console.log('moment().format(): ', moment().format())
console.log('--- end')

--- output ---
[Running] node "c:\lab\temp-ackikjupmw.js"
--- start
C:\lab\temp-ackikjupmw.js:3
console.log('moment().format(): ', moment().format())
^

ReferenceError: moment is not defined
at Object. (C:\lab\temp-ackikjupmw.js:3:36)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Function.Module.runMain (module.js:575:10)
at startup (node.js:160:18)
at node.js:449:3

[Done] exited with code=1 in 0.189 seconds

User input causes program to hang.

Hello,

I'm a total noob at programming, so I appreciate your help and patience. I've been searching around for the best IDE (or IDE-like) setting to learn Python and I think I'd like to settle on VS Code. I'm trying to run a simple program that prompts the user for input, but when I do, the program just hangs indefinitely until I terminate it. I can't input the string and complete the program run. What am I missing? I'm running ht latest version of Python 3.5x. Thanks!
screenshot

Focus on code window while/after run

Any way to keep the focus in the code window when running? Adding option to this plugin or is there any known way already?

I have it open in CS Code terminal in window and after run the cursor is in the terminal so I have to manually click the code again, and then, and then...

👍 this plugin!

Support relative paths to commands

Currently, the extension looks for the command in the OS path. But having global installs is a horrible dev experience. The alternative is to create a npm script (which calls the local install of the npm module) and
create andexecmap in vscode-runner that goes through that npm script. It gets messy.

It would be super nice for the extension to support this:

 "code-runner.executorMap": {
      "mon": "./node_modules/.bin/nodemon",
}

So if you have installed x module (with a runnable) locally, it runs it. This is super helpful when cloning repos and working with modules like babel, nodemon, gulp, etc, etc...Which is the dev's day to day life.

Not taking the VS Code "powershell.developer.powerShellExePath"

Issue Description

I'm using the "Code Runner" VS extension and I'm not able to change PowerShell executable path to point to ver. 6.0.0.10:
"C:/Program Files/PowerShell/6.0.0.10/PowerShell.exe" in "settings.json" file.

Following instructions on link: https://github.com/PowerShell/PowerShell/blob/master/docs/learning-powershell/using-vscode.md

In VS Code Output panel $PSVersionTable results stills shows: PSVersion 5.1.14300.1000.

I did open an incident VS code but the path change works on their Debug option:
"VS Code "powershell.developer.powerShellExePath" not changing path to executable #295"

System Details

  • Operating system name and version: Windows Server 2016 TP5
  • VS Code version: 1.5.2
  • PowerShell extension version: PowerShell 6.0.0-alpha.10
  • Output from $PSVersionTable: See attached image.

Please see attached image.
vscodeposhpathissue

File extensions settings precedence

In my settings:

"code-runner.executorMapByFileExtension": {
    "*.js": "node",
    ".es": "npm run babel-node",
    ".ts": "npm run ts-node"
  },

  // Set the executor of each language.
  "code-runner.executorMap": {
    "sup": "npm run sup",
    "sup-babel": "npm run sup-babel",
    "javascript": "node",
    "php": "php",
    "python": "python",
    "perl": "perl",
    "ruby": "ruby",
    "go": "go run",
    "lua": "lua",
    "groovy": "groovy",
    "powershell": "powershell -ExecutionPolicy ByPass -File",
    "bat": "",
    "shellscript": "bash",
    "fsharp": "fsi",
    "csharp": "scriptcs",
    "vbscript": "cscript //Nologo"
  },

When I run a .es file, it runs node instead of npm run babel-node.
Note: no difference if setting "*.es" or ".es"

Option to remove output info

It would be useful have a setting to remove the pre ([Running]) and post ([Done]) labels in the output console.
thx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.