Registryvsx-synedraauto-run-command

@vsx-synedra/auto-run-command

Public
VSX CompatibleOXP Native: Planned

// Description

Run a vscode command on project init. Made to run wallaby.js automatically when a project is opened

// Readme

Open VSX

#VSCode Extension - auto-run-command

Build Status

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!)

##Usage

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.

ProTip™: Both command and 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!

##Example Settings

  1. Simple -Running wallaby.js when vscode opens on a folder with a config file
"auto-run-command.rules": [
    {
      "condition": "hasFile: wallaby.js",
      "command": "wallaby.start",
      "message": "Running wallaby"
    }
  ]
  1. Running some command (assuming an extension exposed it) when vscode opens on a specific project containing a specific file
"auto-run-command.rules": [
    {
      "condition": [
        "hasFile: special-file",
        "isRootFolder: my-coolz-prodgekt"
      ],
      "command": "crazy-ext.do-magic",
      "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.

##shellCommand

If you set the shellCommand argument to true, then it will run a shell command instead of a VSCode command.

Example:

"auto-run-command.rules": [
  {
    "condition": [
      "hasFile: special-file",
      "isRootFolder: my-coolz-prodgekt"
    ],
    "command": "export COOL_ENV_VARIABLE=cool",
    "message": "Super condition met. Running ",
    "shellCommand": true
  }
]

#Supported rules

ConditionDescriptionArgumentsExample
alwaysIs always truenonealways
hasFileWill only be true if a file exists in the current folderfile name / glob (did not test glob)hasFile: wallaby.js
isLanguageWill run if the first file opened is using a specific language. Not sure how useful is it :)language idisLanguage: typescript
isRootFolderWill run if the name of the root folder in the current workspace matches the argumentfolder nameisRootFolder: my-cool-project
isRunningInContainerWill run if the VSCode instance is running in a containernoneisRunningInContainer

##Release Notes

here


##Contributing

  • To run locally just open the project and debug using vscode.
  • To add more rules check out src/lib/condition-parser.ts and src/lib/condition-checker.ts. Make sure to add a test on the parser too

PR's are welcomed!

VSCode market icon by: Vaadin

Enjoy!

// Install

Open this extension directly in your IDE — no CLI, no extra tools.

Extension ID
synedra.auto-run-command

If your IDE doesn't open automatically, copy the ID above and paste it into the Extensions view (⌘P ext install <id>).

// Source signals

Publisher
Verified ✓
Downloads
1.1M
Published
2021-10-08
License
MIT
Source
repo

Live from open-vsx.org. Refreshed hourly.

// Are you the author?

This listing is mirrored from Open VSX. Claim it to ship a native OXP build, customise the page, and respond to reviews.

Claim this listing

// Package Info

Version
1.6.1
Owner
@vsx-synedra
Downloads
1.0M
Stars
0