Skip to content

cannd/script-runner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Script runner for Visual Studio Code

By default, this extension display a "Run script" button above every function call script('Script name', whatever) in any files end with .script.{js,ts,tsx,jsx} The function name, button(s) and command(s) can be customized. For example to add button(s) for function foo, add the following settings to either .vscode/settings.json, extension settings or User settings. The "foo" is required, while other "foo-*" are to add more command buttons

{
  "fbc.scriptrunner.functions": {
    "foo": {
      "command": "npx tsx {filePath} {scriptName}",
      "title": "Run with tsx"
    },
    "foo-whatever-1": {
      "command": "npx ts-node {filePath} {scriptName}",
      "title": "Run with ts-node"
    },
    "foo-whatever-2": {
      "command": "echo 'Hello, world'",
      "title": "Hello"
    },
  }
}

Example of usage:

result

And the corresponding configuration file (.vscode/settings.json): configuration

Configuration

.vscode/settings.json

You can use the following configurations to customize the behavior of the Script runner extension.

{
  "fbc.scriptrunner.filePattern": {
    "type": "string",
    "default": "**/*.script.{js,ts,tsx,jsx}",
    "description": "Glob pattern to match test files (e.g., **/*.script.{js,ts,tsx,jsx})"
  },
  "fbc.scriptrunner.functions": {
    "type": "object",
    "additionalProperties": {
      "type": "object",
      "properties": {
        "command": {
          "type": "string",
          "description": "Command to execute. Supported variables: {filePath} {scriptName}",
          "default": "npx tsx {filePath} {scriptName}"
        },
        "title": {
          "type": "string",
          "description": "Title to display",
          "default": "Run script"
        }
      }
    },
    "default": {
      "script": {
        "command": "npx tsx {filePath} {scriptName}",
        "title": "Run script"
      }
    }
  }
}

About

A VS Code plugin to execute scripts

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published