Commands Refresh
A lightweight VS Code extension that executes a configurable command whenever a selected task completes successfully.
The extension monitors task execution and triggers the configured VS Code command only when the task name matches one of the specified entries and its process exits with code 0.
Features
- Monitor selected VS Code tasks.
- Execute any registered VS Code command after successful task completion.
- Configure monitored tasks and commands through VS Code Settings.
- Automatically trigger commands without additional user interaction.
- Lightweight implementation using the VS Code Extension API.
Installation
Install locally for development
- Clone or extract this repository into a permanent folder.
- Open the project folder in VS Code.
- Press
F5 to launch an Extension Development Host window.
- Configure the tasks you want to monitor in the Extension Development Host.
- Execute one of the configured tasks.
- Confirm that the configured command is executed successfully.
Install using VSIX
Package the extension using vsce:
npx @vscode/vsce package
Install the generated .vsix file using the VS Code command:
code --install-extension commands-refresh-1.0.0.vsix
Configuration
The extension can be configured through VS Code Settings.
Open your settings.json file and add the following configuration:
{
"commandsRefresh.taskNames": [
"Build Project",
"Deploy Application",
"My Custom Task"
],
"commandsRefresh.commandId": "commands.refresh"
}
Configuration properties
| Property |
Description |
Default |
commandsRefresh.taskNames |
List of exact task names to monitor. |
[] |
commandsRefresh.commandId |
VS Code command to execute after a successful task. |
commands.refresh |
Note: Task names must match the corresponding VS Code task labels exactly.
Example: Commands extension integration
By default, the extension is configured to execute commands.refresh, which is provided by the Commands extension.
Make sure the Commands extension is installed and enabled if you want to use this integration.
You can also configure a different command ID from another VS Code extension or a built-in VS Code command.
How It Works
The extension listens for task process completion events through the VS Code Extension API:
vscode.tasks.onDidEndTaskProcess
When a task finishes:
- The extension checks whether its name matches one of the configured task names.
- It verifies whether the process exit code is
0.
- If both conditions are satisfied, it executes the configured VS Code command.
Tasks that are not configured or that finish with an error do not trigger the command.
Troubleshooting
Open View > Output and select Commands Refresh to inspect the extension's activity.
If the configured command is not executed, check the following:
- The task name matches an entry in
commandsRefresh.taskNames.
- The task completed successfully (exit code
0).
- The configured command ID is valid and available.
- The extension providing the configured command is installed and enabled, if applicable.
License
This project is licensed under the MIT License.
See the LICENSE file for details.