@jayansh123/clean-logs
v1.0.1
Published
A CLI tool to scan and safely remove console statements from JavaScript and TypeScript projects.
Maintainers
Readme
Clean Logs CLI
A lightweight CLI tool to scan and remove console statements from JavaScript and TypeScript projects.
Features
- 🔍 Scan your project for console statements
- 🧹 Remove console statements safely
- 👀 Preview changes with
--dry-run - ⚡ Remove all supported console methods with
--all - 💾 Create a backup before modifying files
- 📦 Works as a reusable CLI across projects
- 🚫 Automatically ignores common directories such as
node_modules,.git,dist,.next, andbuild
Installation
Using npx
No installation is required:
npx @jayansh123/clean-logs --helpGlobal installation
npm install -g @jayansh123/clean-logsAfter installation, you can use:
clean-logs --helpUsage
Run the CLI from the root directory of your project.
Scan the project
By default, the tool scans for console.log statements:
clean-logsThe tool will show the detected console statements and ask for confirmation before removing them.
Dry Run
To scan the project without modifying any files:
clean-logs --dry-runThis is useful when you want to see what will be removed before making any changes.
Remove All Supported Console Methods
To remove all supported console methods:
clean-logs --allDry Run with All Methods
To preview the removal of all supported console methods:
clean-logs --all --dry-runSkip Confirmation
To remove the detected console statements without the confirmation prompt:
clean-logs --yesFor all supported methods:
clean-logs --all --yesSupported Console Methods
The CLI supports the following console methods:
console.logconsole.warnconsole.errorconsole.infoconsole.debug
By default, only console.log is removed.
Use --all to remove all supported methods.
Backup
Before modifying a file, Clean Logs creates a backup containing the console statements that are going to be removed.
For example:
src/example.ts
src/example.ts.clean-logs-backupThe backup contains only the console statements removed during that operation, rather than the entire source file.
If the backup already exists, it is replaced with the latest backup.
Ignored Directories
Clean Logs automatically skips these directories:
node_modules
.git
.next
dist
build
coverage
outThis prevents dependencies, generated files, and build output from being modified.
Examples
Preview console.log removal
npx @jayansh123/clean-logs --dry-runRemove console.log
npx @jayansh123/clean-logsRemove all supported console methods
npx @jayansh123/clean-logs --allRemove all methods without confirmation
npx @jayansh123/clean-logs --all --yesHelp
To see all available options:
npx @jayansh123/clean-logs --helpOptions
| Option | Description |
| -------------- | ------------------------------------ |
| --all | Remove all supported console methods |
| --dry-run | Scan only without modifying files |
| --yes | Skip the confirmation prompt |
| --help, -h | Show help information |
| --version | Show the current version |
Supported File Types
Clean Logs scans:
.ts.tsx.js.jsx
Requirements
- Node.js
- npm
Package
npm: @jayansh123/clean-logs
License
MIT
