remove-comments-tool
v1.0.3
Published
A tool to remove comments from JavaScript/TypeScript files
Downloads
201
Readme
Remove Comments Tool
remove-comments-tool
is a command-line utility that removes comments from JavaScript, TypeScript, JSX, and TSX files. This tool is particularly useful for preparing code for production or reducing file size by eliminating unnecessary comments.
Features
- Removes single-line (
//
) and multi-line (/* */
) comments. - Preserves string literals, ensuring that comments within strings are not removed.
- Recursively processes directories to remove comments from all supported files.
Installation
You can install the tool globally using NPX:
npx remove-comments-tool <path-to-file-or-directory>
Usage
To remove comments from a specific file:
npx remove-comments-tool path/to/your/file.js
To remove comments from all supported files in a directory:
npx remove-comments-tool path/to/your/directory
Supported File Types
- JavaScript (.js)
- TypeScript (.ts)
- JSX (.jsx)
- TSX (.tsx)
Example
npx remove-comments-tool ./src
This command will remove comments from all .js
, .ts
, .jsx
, and .tsx
files in the src
directory and its subdirectories.
Notes
- Please ensure you have backups of your files before running this tool, as it directly modifies the original files.
- This tool uses Node.js, so make sure you have Node.js installed on your machine.