js-logs-remover
is a command-line utility written in Rust that removes specified console
logging methods (e.g., console.log()
, console.error()
) from JavaScript/TypeScript files within a directory. This tool is useful for cleaning up log statements before deploying or publishing code.
- Removes specified
console
methods from JavaScript, TypeScript, JSX, and TSX files. - Processes files recursively within directories, excluding certain common directories such as
node_modules
,.git
,dist
, andbuild
. - Supports both specified log methods and a global "all" option to remove all defined
console
methods.
To install js-logs-remover
, you must have Rust installed on your machine.
-
Clone the repository:
git clone https://github.com/BaseMax/js-logs-remover-rust.git
-
Navigate to the directory:
cd js-logs-remover-rust
-
Build the Rust application:
cargo build --release
After building, you will have a js-logs-remover binary in the project directory.
target
├── debug
└── release
└── js-logs-remover.exe
Run the tool from the command line:
$ js-logs-remover [path] [log-methods]
[path]
: The directory or file path where you want to remove the logs from. If no path is provided, it defaults to the current directory (.).
[log-methods]
: A comma-separated list of console methods you want to remove (e.g., log,error,warn). If you specify all, it will remove all known console methods.
Remove specific console methods: To remove console.log and console.warn from all .js, .ts, .jsx, and .tsx files within the src directory:
$ js-logs-remover src log,warn
Remove all console methods: To remove all console methods (like console.log, console.error, etc.) from all files in the src directory:
$ js-logs-remover src all
Process the current directory: To process the current directory and remove console.log:
$ js-logs-remover . log
The following directories are automatically excluded from processing:
- node_modules
- .git
- dist
- build
This project is licensed under the MIT License - see the LICENSE file for details.
© 2025 Max Base. All rights reserved.