Package: vscode-task-runner
VS Code Task RunnerThis is a command-line tool to execute VS Codetasksdefined in the.vscode/tasks.jsonfile.
This allows you to write tasks once, and be able to run them in your editor,
and in CI/CD. Basically, use.vscode/tasks.jsonas a Makefile.This tool aims to be as feature-complete as possible with what VS Code supports for
Windows, MacOSX and Linux. Much of the logic is taken directly from the VS Code
source code and reimplemented in Python.This pairs well with VS Code extensions that add buttons to run tasks such asactboy168.tasks.UsagePython 3.8+ is required.Install with pip/pipx:pipinstallvscode-task-runnerUse the commandvtron the command line and provide the label of the task(s).
There must be a.vscode/tasks.jsonfile in the working directory you run the
command in. (You can also use thevscode-task-runnercommand instead
if it makes you feel better).Examples{"version":"2.0.0","tasks":[{"label":"pre-commit","type":"shell","command":"poetry run pre-commit run --all-files"}]}$vtrpre-commit[1/1]Executingtask"pre-commit":C:\ProgramFiles\WindowsApps\Microsoft.PowerShell_7.3.4.0_x64__8wekyb3d8bbwe\pwsh.exe-Commandpoetryrunpre-commitrun--all-files
checkjson...............................................................Passed
checktoml...............................................................Passed
checkyaml...............................................................Passed
checkforcaseconflicts.................................................Passed
trimtrailingwhitespace.................................................Passed
checkformergeconflicts................................................Passed
mixedlineending........................................................Passed
poetry-check.............................................................Passed
poetry-lock..............................................................Passed
absolufy-imports.........................................................Passed
ruff.....................................................................Passed
black....................................................................Passed
pyleft...................................................................Passed
pyright..................................................................Passed
markdownlint.............................................................PassedAdditionally, for convenience, extra arguments can be tacked on to a task.
For example, you can add extra settings or overrides when running in CI/CD.
Continuing the example above:$vtrpre-commit--color=always--show-diff-on-failure[1/1]Executingtask"pre-commit":C:\ProgramFiles\WindowsApps\Microsoft.PowerShell_7.3.4.0_x64__8wekyb3d8bbwe\pwsh.exe-Commandpoetryrunpre-commitrun--all-files--color=always--show-diff-on-failure
checkjson...............................................................Passed
checktoml...............................................................Passed
checkyaml...............................................................Passed
checkforcaseconflicts.................................................Passed
trimtrailingwhitespace.................................................Passed
checkformergeconflicts................................................Passed
mixedlineending........................................................Passed
poetry-check.............................................................Passed
poetry-lock..............................................................Passed
absolufy-imports.........................................................Passed
ruff.....................................................................Passed
black....................................................................Passed
pyleft...................................................................Passed
pyright..................................................................Passed
markdownlint.............................................................PassedThis can only be used when running a single task.If your task uses an${input:id}variable, you can provide the value for
this variable as an environment variable namedVTR_INPUT_{id}. Example:{"version":"2.0.0","tasks":[{"label":"tests","command":"pytest --cov=vtr/ --cov-report ${input:report_format}","type":"shell"}],"inputs":[{"id":"report_format","description":"Coverage report format","type":"pickString","options":["html","xml","annotate","json","lcov"]}]}Then in GitHub Actions:-name:Run testsrun:vtr testsenv:VTR_INPUT_report_format:htmlThedependsOnkey is also supported:{"version":"2.0.0","tasks":[{"label":"install","type":"shell","command":"poetry install --sync"},{"label":"build","type":"shell","command":"poetry build","dependsOn":["install"]}]}$vtrbuild[1/2]Executingtask"install":C:\ProgramFiles\WindowsApps\Microsoft.PowerShell_7.3.4.0_x64__8wekyb3d8bbwe\pwsh.exe-Commandpoetryinstall--sync
Installingdependenciesfromlockfile

Nodependenciestoinstallorupdate

Installingthecurrentproject:vscode-task-runner(0.1.1)[2/2]Executingtask"build":C:\ProgramFiles\WindowsApps\Microsoft.PowerShell_7.3.4.0_x64__8wekyb3d8bbwe\pwsh.exe-Commandpoetrybuild
Buildingvscode-task-runner(0.1.1)-Buildingsdist-Builtvscode_task_runner-0.1.1.tar.gz-Buildingwheel-Builtvscode_task_runner-0.1.1-py3-none-any.whlYou can also use it as apre-commithook if desired:repos:-repo:https://github.com/NathanVaughn/vscode-task-runnerrev:v0.1.7hooks:-id:vtr# Optionally override the hook name here# name: Build & Testargs:-build# put the tasks you want to run here-testThe pre-commit hook does not match on any file types, and and will always execute.If usingpre-commitandpoetryis part of your task, you may need to add the
following"options":{"env":{"VIRTUAL_ENV":"${workspaceFolder}${pathSeparator}.venv"}}and setvirtualenvs.in-projecttotrue.Otherwise,poetrymay think thepre-commitvirtual environment is your
project's virtual environment.Implemented FeaturesPredefined variables:${userHome}${workspaceRoot}${workspaceFolder}${workspaceFolderBasename}${pathSeparator}${/}${defaultBuildTask}${cwd}${env:VARIABLE}${input:VARIABLE}Settings hierarchy:Global level settingsGlobal level OS-specific settingsTask level settingsTask level OS-specific settingsTask configuration:cwdenvtype"process""shell"commandargsshellexecutableargsdependsOnQuoting support:"escape""strong""weak"Unsupported FeaturesAny predefined variable not listed above. The other variables tend to rely
upon the specific file opened in VS Code, or VS Code itself.Variables scoped to workspace foldersCommand variablesInput command variablesProblem matchersBackground tasksUNC path conversionParalleldependsOntask executionTask types other than"process"or"shell"(such as"npm","docker", etc.)Differences from VS CodeIf a task is of type"shell", and a specific shell is not defined, the parent
shell will be usedOnly schema version 2.0.0 is supportedIf nocwdis specified, the current working directory is used for the task insteadDoes not support any extensions that add extra options/functionalityDoes not load any VS Code settingsExtra arguments optionVTR_INPUT_${id}environment variables