An interactive command-line tool to list and execute npm scripts from your package.json file. This tool provides a user-friendly interface to view and run your npm scripts without having to remember or type the exact script names.
- 📋 Lists all available npm scripts from package.json
- 🔍 Shows the actual command for each script
- 🎯 Interactive script selection
- 🎨 Color-coded output for better readability
- 🔄 Option to run multiple scripts consecutively
⚠️ Comprehensive error handling
- Python 3
- npm
- Download the script:
curl -O https://raw.githubusercontent.com/yourusername/npm-script-runner/main/npm-script-runner.sh
- Make it executable:
chmod +x npm-script-runner.sh
- (Optional) Move to a directory in your PATH for global access:
sudo mv npm-script-runner.sh /usr/local/bin/npm-script-runner
- Navigate to your Node.js project directory:
cd your-project-directory
- Run the script:
./npm-script-runner.sh
Or if installed globally:
npm-script-runner
- Select a script by entering its number when prompted.
Given a package.json with the following scripts:
{
"scripts": {
"start": "node index.js",
"dev": "nodemon index.js",
"test": "jest",
"build": "webpack --mode production",
"lint": "eslint ."
}
}
The tool will display:
Available scripts:
1) start
→ node index.js
2) dev
→ nodemon index.js
3) test
→ jest
4) build
→ webpack --mode production
5) lint
→ eslint .
Enter the number of the script to run (1-5) or 'q' to quit:
The script includes error handling for:
- Missing package.json file
- Invalid JSON in package.json
- Missing required dependencies
- Invalid user input
- Missing scripts in package.json
Feel free to submit issues and enhancement requests!
This project is licensed under the MIT License - see the LICENSE file for details.
Izac Cavalheiro