Run a command when VSCode starts, based on some conditions.
Built to run Wallaby.js automatically on projects that have a config.
I decided to make it a bit more generic to play around with the API (and because developing an extension there is super smooth! Awesome work VSCode guys!)
The way this extension works is by reading a list of rules from your settings.
Each rule is evaluated and if the rule's condition is met, a command is ran.
A rule consists of a condition, a command and an optional message. The message will be shown if the condition is met.
You need to open your settings: File -> Preferences -> User Settings, and add a rule. Check below for examples.
condition accept arrays. If you pass in multiple conditions, all of them have to be met. If multiple commands are passed, all of them will run.
Note: commands run after a 5s delay to ensure the command was registered. If there's a better way to do that other than delaying, let me know!
- Simple -Running wallaby.js when vscode opens on a folder with a config file
"condition": "hasFile: wallaby.js",
"message": "Running wallaby"
- Running some command (assuming an extension exposed it) when vscode opens on a specific project containing a specific file
"message": "Super condition met. Running "
If you find a real usage for this other than wallaby.js I'll be glad to know! Leave a message in the issues part.
||Is always true
||Will only be true if a file exists in the current folder
||file name / glob (did not test glob)
||Will run if the first file opened is using a specific language. Not sure how useful is it :)
||Will run if the name of the root folder in the current workspace matches the argument
- To run locally just open the project and debug using vscode.
- To add more rules check out
src/lib/condition-checker.ts. Make sure to add a test on the parser too
PR's are welcomed!
VSCode market icon by: Vaadin