Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running a task of Visual Studio Code from the command line

Tags:

I've a simple project in visual studio code with some defined tasks in tasks.json. Let's say the task are labeled with foo and bar.

Inside of visual studio code I can run CTRL+B and select the wanted task.

But - How can I run the task foo from a command line outside of Visual Studio Code?

like image 977
powerpete Avatar asked Feb 07 '19 07:02

powerpete


People also ask

How do I run a task in Visual Studio Code?

To run tasks from VS Code we need a configure the Task Runner. This is done by entering the Command Palette (F1 or ctrl-shift-p), typing task and selecting Tasks: Configure Task Runner.

How do I execute a command in Visual Studio Code?

Executing Commands. To run tasks from VS Code we need a configure the Task Runner. This is done by entering the Command Palette (F1 or ctrl-shift-p), typing task and selecting Tasks: Configure Task Runner. Configure the Task Runner in VS Code. This will create a tasks.json file under the .vscode directory in the current folder.

Is there a way to run a task from the command line?

If its tasks can be run in command line, the command line needs to read tasks.json and parse it, it sounds not a good idea. You can make a same foo.sh instead of foo task in vscode, it can run well and more expansible.

How do I run code in Visual Studio Code on macOS?

To do this, from an open terminal or command prompt, navigate to your project folder and type code .: Note: Users on macOS must first run a command ( Shell Command: Install 'code' command in PATH) to add VS Code executable to the PATH environment variable. Read the macOS setup guide for help.


Video Answer


1 Answers

There is a python tool that runs the vscode tasks. The last commit was in 2018, but it still might work as it seems that the tasks were last changed in vscode 1.13, released in 2017.

edit:
It works but setup.py:8 needs to be edited to build the wheel on windows, as it tries to run a shell script. My edit was to change the line to log = subprocess.check_output('sh bin/changelog') as I have sh installed.

like image 92
ompadu Avatar answered Sep 20 '22 07:09

ompadu