Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to chain tasks in Visual Studio Code using only tasks.json?

Tags:

I have been ploughing through the documentation of Visual Studio Code to figure out how to add multiple consecutive tasks to the tasks.json file.

The tasks array only allows for creating different arguments to the same command. In this example the command is echo.

{     "version": "0.1.0",     "command": "echo",     "isShellCommand": true,     "args": [],     "showOutput": "always",     "echoCommand": true,     "suppressTaskName": true,     "tasks": [         {             "taskName": "hello",             "args": ["Hello World"]         },         {             "taskName": "bye",             "args": ["Good Bye"]         }     ] } 

Does tasks.json allow several tasks to be executed consecutively? For example, tsc followed by uglify?

like image 493
Kokodoko Avatar asked Apr 27 '17 12:04

Kokodoko


People also ask

How do I run multiple tasks in vscode?

Note that the definition is a list, so more than one task can be specified. In that case the tasks are executed in parallel. In your case adding "dependsOn":["Compile/minify cms. scss"] to your main build task should execute both tasks.

What is task json?

tasks. json is used to execute anything else you may want, be that source code formatters, bundlers or a SASS compiler. To use a configuration from tasks. json , you select Run Task from the command list.

How do I create a To Do list in Visual Studio code?

Double-clicking a TODO in the tree will open the file and put the cursor on the line containing the task. In open files, TODOs can also be highlighted for easier navigation. You can further customize the extension by specifying specific flags in VSCode settings, more details can be found at TODO Tree wiki page.


Video Answer


1 Answers

The dependsOn feature was shipped in version 1.10.0. For example, I am using this to compile and run single file scripts in TypeScript:

{     "version": "2.0.0",     "tasks": [         {             "command": "tsc -p ${cwd}/2017-play",             "label": "tsc-compile",             "type": "shell"         },         {             "command": "node ${cwd}/2017-play/build/${fileBasenameNoExtension}.js",             "label": "node-exec",             "type": "shell",             "dependsOn": [                 "tsc-compile"             ],             "problemMatcher": []         }     ] } 
like image 130
Ben Creasy Avatar answered Sep 25 '22 09:09

Ben Creasy