https://github.com/knowledgecode/ejs-cli-extended
Extended EJS CLI tool with directory processing and watch functionality
https://github.com/knowledgecode/ejs-cli-extended
build cli compiler ejs template watch
Last synced: 5 months ago
JSON representation
Extended EJS CLI tool with directory processing and watch functionality
- Host: GitHub
- URL: https://github.com/knowledgecode/ejs-cli-extended
- Owner: knowledgecode
- License: mit
- Created: 2025-08-13T02:50:39.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2025-08-13T07:39:16.000Z (5 months ago)
- Last Synced: 2025-08-13T15:40:17.523Z (5 months ago)
- Topics: build, cli, compiler, ejs, template, watch
- Language: TypeScript
- Homepage:
- Size: 42 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# EJS CLI Extended
Extended EJS CLI tool with directory processing and watch functionality.
[](https://github.com/knowledgecode/ejs-cli-extended/actions/workflows/ci.yml)
[](https://www.npmjs.com/package/ejs-cli-extended)
## Features
- 🗂️ **Directory Processing**: Process all `.ejs` files in a directory recursively
- 👀 **Watch Mode**: Automatically recompile templates when files change
- ⚡ **Concurrent Processing**: Multiple templates can be processed simultaneously
- 🔄 **100% Compatible**: Directly executes the official EJS CLI, ensuring perfect compatibility
## Installation
### Global Installation
```bash
npm install -g ejs-cli-extended
```
### Local Installation
```bash
npm install ejs-cli-extended
```
When installed locally, you can run it with:
```bash
# Using npx
npx ejsc src:dist
# Using npm scripts
npm exec ejsc src:dist
# Or add to your package.json scripts
"scripts": {
"build": "ejsc src:dist"
}
```
## Usage
### Single File Mode
Process a single EJS template file:
```bash
ejsc template.ejs -o output.html
ejsc template.ejs -f data.json -o output.html
```
### Directory Mode
Process all `.ejs` files in a directory:
```bash
ejsc src:dist
ejsc templates:build -f config.json
```
### Watch Mode
Continuously watch for changes and recompile:
```bash
# Single file
ejsc template.ejs -o output.html --watch
# Directory
ejsc src:dist --watch
```
## Options
### Standard EJS CLI Options
All standard EJS CLI options are supported. For complete documentation, see the [official EJS CLI repository](https://github.com/mde/ejs?tab=readme-ov-file#cli).
### Extended Options
- `--watch` - Watch for changes and recompile automatically
- `input-dir:output-dir` - Process directory (replaces single file path)
## Examples
### Basic Directory Processing
```bash
# Process all .ejs files in 'templates' directory
# Output to 'dist' directory
ejsc templates:dist
```
### With Data File
```bash
# Use JSON data file for template variables
ejsc src:build -f data.json
```
### Watch Mode
```bash
# Watch for changes and auto-recompile
ejsc templates:dist --watch -f config.json
```
## Directory Structure
When using directory mode, the tool:
1. Recursively finds all `.ejs` files in the input directory
2. Maintains the same directory structure in the output
3. Converts `.ejs` extensions to `.html`
4. Creates output directories as needed
Example:
```text
src/
├── index.ejs → dist/index.html
├── pages/
│ ├── about.ejs → dist/pages/about.html
│ └── contact.ejs → dist/pages/contact.html
└── components/
└── header.ejs → dist/components/header.html
```
## Complete EJS CLI Compatibility
This tool directly executes the official EJS CLI, ensuring 100% compatibility. All EJS CLI features are supported, including:
- All command-line options and flags
- Data input via files, command line, or stdin pipe
- Template preprocessing and compilation
- Custom delimiters and configurations
```bash
# All these work exactly like the official EJS CLI
ejsc template.ejs -o output.html
ejsc template.ejs -f data.json -o output.html
echo '{"name": "World"}' | ejsc template.ejs -o output.html
ejsc template.ejs -m $ -p [ -c ] -o output.html
```
You can use this tool as a complete drop-in replacement for the official EJS CLI.
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.