NPM Runner Extension
A VS Code extension to run NPM scripts defined in package.json from a sidebar tree view.
Features
- Sidebar Tree View: Displays all NPM scripts from package.json in a tree structure
- Script Execution: Run any script with a single click
- Terminal Integration: Choose between integrated VS Code terminal or external terminal
- Auto Refresh: Automatically refreshes script list when package.json changes
- Predefined Scripts: Quick access to common scripts (start, dev, build, test, lint)
- Configuration: Customize package.json path, terminal behavior, and auto-refresh settings
Usage
- Open the NPM Runner extension
- Click on the "NPM Scripts" icon in the Activity Bar
- All scripts from your package.json will be displayed
- Click on a script to run it
- Choose "Run in Terminal" to execute in VS Code's integrated terminal
- Choose "Open in External Terminal" to execute in your system's default terminal
Configuration
Settings
- packageJsonPath: Path to package.json file (default: `./package.json`)
- autoRefresh: Automatically refresh script list when package.json changes (default: `true`)
- showPredefinedScripts: Show predefined scripts (start, dev, build, test, lint) (default: `true`)
- terminalBehavior: Terminal behavior - `integrated` or `external` (default: `integrated`)
- clearTerminalBeforeRun: Clear terminal before running script (default: `false`)
Commands
- `npmRunner.runScript`: Run selected script
- `npmRunner.refresh`: Refresh script list
- `npmRunner.openTerminal`: Open in integrated terminal
- `npmRunner.openInIntegratedTerminal`: Run in integrated terminal
- `npmRunner.openSettings`: Open extension settings
Architecture
The extension follows a clean separation of concerns:
- NpmScriptProvider: Handles tree data and file system watching
- TerminalService: Manages terminal creation and script execution
- Main Extension: Coordinates providers and commands
Development
Building
```bash
npm install
npm run compile
```
Running in Development Mode
```bash
code --extensionDevelopmentPath=./npm-runner .
```
Installation
- Build the extension: `npm run compile`
- Package the extension: `vsce package`
- Install in VS Code: Extensions → Install from VSIX...
License
MIT
| |