A simple command-line tool that counts lines of code in your project, excluding comments. It supports TypeScript, JavaScript, and Python files.
- 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
npm install -g count-linesSimply 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.
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 languagesCount-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
We welcome contributions to Count-Lines! Here's how you can help:
- 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 install- 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"- 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
- Use consistent indentation (2 spaces)
- Follow TypeScript best practices
- Add comments for complex logic
- Update documentation for any new features
MIT