Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Define multiple tasks in VSCode

I have seen that it is possible to define a task in the VSCode. But I am not sure how to define multiple tasks in the tasks.json file.

like image 500
Franz Gsell Avatar asked May 05 '15 07:05

Franz Gsell


People also ask

How do I add a task in Visual Studio?

On the Tools menu, choose Options. Open the Environment folder and then choose Task List.


1 Answers

Just in case it helps someone... . If you don't have/want gulp/grunt/etc... or an extra shell script to proxy out your task commands , "npm run" is there already .

this is for webpack and mocha as in "Build and Test" , Shift+Ctrl+B, Shift+Ctrl+T

.vscode/tasks.json:

{   "name": "npmTask",   //...   "suppressTaskName": true,   "command": "npm",   "isShellCommand": true,   "args": [     "run"   ],   "tasks": [     {       //Build Task       "taskName": "webpack",       //Run On Shift+Ctrl+B       "isBuildCommand": true,       //Don't run when Shift+Ctrl+T       "isTestCommand": false,       // Show the output window if error any       "showOutput": "silent",       //Npm Task Name       "args": [         "webpack"       ],       // use 2 regex:       // 1st the file, then the problem              "problemMatcher": {         "owner": "webpack",         "severity": "error",         "fileLocation": "relative",         "pattern": [           {             "regexp": "ERROR in (.*)",             "file": 1           },           {             "regexp": "\\((\\d+),(\\d+)\\):(.*)",             "line": 1,             "column": 2,             "message": 3           }         ]       }     },     {       //Test Task          "taskName": "mocha",       // Don't run on Shift+Ctrl+B       "isBuildCommand": false,       // Run on Shift+Ctrl+T       "isTestCommand": true,       "showOutput": "always",       "args": [         "mocha"       ]     }   ] } 

package.json:

{   ...   "scripts": {     "webpack": "webpack",     "mocha": "/usr/bin/mocha"   },   ... } 
like image 107
Dan Avatar answered Oct 13 '22 06:10

Dan