Skip to content

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.

Notifications You must be signed in to change notification settings

izaccavalheiro/npm-script-runner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

NPM Script Runner

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.

Features

  • 📋 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

Prerequisites

  • Python 3
  • npm

Installation

  1. Download the script:
curl -O https://raw.githubusercontent.com/yourusername/npm-script-runner/main/npm-script-runner.sh
  1. Make it executable:
chmod +x npm-script-runner.sh
  1. (Optional) Move to a directory in your PATH for global access:
sudo mv npm-script-runner.sh /usr/local/bin/npm-script-runner

Usage

  1. Navigate to your Node.js project directory:
cd your-project-directory
  1. Run the script:
./npm-script-runner.sh

Or if installed globally:

npm-script-runner
  1. Select a script by entering its number when prompted.

Example

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:

Error Handling

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

Contributing

Feel free to submit issues and enhancement requests!

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Izac Cavalheiro

About

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.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages