project-line-counter
v1.0.2
Published
A simple CLI tool to count lines of code by language.
Downloads
11
Maintainers
Readme
Count-Lines
A simple command-line tool that counts lines of code in your project, excluding comments. It supports TypeScript, JavaScript, and Python files.
Features
- Counts non-comment lines of code in your project
- Skips
node_modulesand hidden folders - Works with TypeScript (.ts, .tsx), JavaScript (.js, .jsx), and Python (.py) files
- Interactive mode with easy language selection
- Command-line flags for quick counting
Installation
npm install -g count-linesUsage
Interactive Mode
Simply run the command without any flags to enter interactive mode:
count-linesYou'll be prompted to select which language you want to count or choose "All" to count all supported languages.
Command-line Flags
You can also use command-line flags to specify which language to count:
count-lines --typescript # Count only TypeScript files
count-lines --javascript # Count only JavaScript files
count-lines --python # Count only Python files
count-lines --all # Count all supported languagesHow It Works
Count-Lines works by:
- Scanning your project directory (excluding node_modules and hidden folders)
- Identifying files with the selected extensions
- Reading each file and removing comment lines:
- For JavaScript/TypeScript: Removes both /_ block comments _/ and // line comments
- For Python: Removes # line comments
- Counting the remaining lines of code
- Displaying a summary with files scanned and total lines count
Contributing
We welcome contributions to Count-Lines! Here's how you can help:
Setting Up for Development
- Fork the repository on GitHub
- Clone your fork to your local machine:
git clone https://github.com/TTibbs/project-line-counter- Install dependencies:
cd count-lines
npm installMaking Changes
- Create a new branch for your changes:
git checkout -b your-feature-branch- Make your changes to the code
- Test your changes thoroughly
- Commit your changes with a descriptive message:
git commit -m "Add support for new language"Submitting a Pull Request
- Push your changes to your fork:
git push origin your-feature-branch- Go to the original repository on GitHub
- Click "New Pull Request"
- Select your fork and branch
- Add a title and description explaining your changes
- Submit the pull request
Code Style
- Use consistent indentation (2 spaces)
- Follow TypeScript best practices
- Add comments for complex logic
- Update documentation for any new features
License
MIT
