Reputation: 2700
I want to add a task to my VS Code tasks.json file that can rerun the last task that I ran.
I know there is a command Rerun Last Task
that I can use when I press F1
to Show All Commands
. However, not every developer knows about typing F1
to show all commands, but they know about F7
for build tasks. That's why I want to add something to our baseline tasks.json.
Is there a way to somehow call the Rerun Last Task
command in tasks.json? Or maybe there is a variable that has the last task run?
Upvotes: 0
Views: 1198
Reputation: 182591
{
"label": "rerun last command",
"command": "${command:workbench.action.tasks.reRunTask}",
"type": "shell",
"problemMatcher": [],
},
That task will rerun the last task. You see you can make any command into a variable for use within launch.json or tasks.json with the form:
${command:some command ID here}
See https://code.visualstudio.com/docs/editor/variables-reference#_command-variables
That creates a "command variable" which can be used as an argument or as a command.
Upvotes: 1