Usage Guide
Command Line Options
remove-comments [options] <file...>
Options
-o, --output <dir>- Output directory for processed files-i, --in-place- Modify files in place-k, --keep-protected- Keep protected comments (//! and /*!)-v, --verbose- Show detailed processing information-h, --help- Display help information
Examples
Basic Usage
Remove comments from a single file:
remove-comments src/index.js
Process Multiple Files
Remove comments from all JavaScript files in a directory:
remove-comments src/**/*.js
Keep Protected Comments
Preserve comments that start with //! or /*!:
remove-comments --keep-protected src/index.js
In-place Modification
Modify files directly instead of creating new ones:
remove-comments --in-place src/**/*.ts
Custom Output Directory
Save processed files to a specific directory:
remove-comments -o dist src/**/*.js
Comment Types
The tool handles various types of comments:
Single-line Comments
// This comment will be removed
//! This protected comment will be preserved
Multi-line Comments
/* This comment will be removed */
/*! This protected comment will be preserved */
JSDoc Comments
/**
* This JSDoc comment will be preserved
* @param {string} name
* @returns {void}
*/
Edge Cases
The tool properly handles various edge cases:
- Comments in string literals
- Nested comments
- Mixed comment types
- Comments in template literals
- URL-like content in strings