lfify
v1.3.0
Published
make your crlf to lf
Downloads
219
Readme
LFify
A lightweight Node.js program to convert CRLF to LF line endings.
It is useful when your development environment is Windows.
Getting started
You can run LFify from git hooks using Husky or Lefthook.
Config file
Create .lfifyrc.json in your root directory of project:
{
"entry": "./",
"include": [
"**/*.{js,ts,jsx,tsx}",
"**/*.{json,md}",
"**/*.{css,scss}",
"**/*.{html,vue}"
],
"exclude": [
"node_modules/**",
".git/**",
"dist/**",
"build/**",
"coverage/**"
],
"logLevel": "error"
}Husky
Install Husky and create a pre-commit hook:
npm install -D husky
npx husky initEdit .husky/pre-commit so it runs LFify (add or replace the file contents):
npx lfifyLefthook
Add lefthook.yml at the repository root:
pre-commit:
commands:
lfify:
run: npx lfifyInstall Lefthook hooks (once per clone):
npx lefthook installManual execution
npx lfify --include "**/*.js" --exclude "node_modules/**"CLI Options
| Option | Description |
| --------------------- | ----------------------------------------------------------------------------- |
| [path] | Positional shorthand for --entry. A directory is traversed, a single file is converted as-is. |
| --config <path> | Specify a custom path for the configuration file. Default is .lfifyrc.json. |
| --entry <path> | Specify the entry path to process (file or directory). Default is ./. |
| --include <pattern> | Glob pattern(s) to include. Can be used multiple times. |
| --exclude <pattern> | Glob pattern(s) to exclude. Can be used multiple times. |
| --log-level <level> | Set log level: error, warn, or info. Default is error. |
When both --entry and a positional path are given, --entry takes precedence.
When the entry is a single file, it is converted directly and include/exclude patterns are ignored.
Examples
# Process all JavaScript files, exclude node_modules
npx lfify --include "**/*.js" --exclude "node_modules/**"
# Process multiple file types
npx lfify --include "**/*.js" --include "**/*.ts" --exclude "node_modules/**" --exclude ".git/**"
# Process files in a specific directory
npx lfify --entry ./src --include "**/*.js"
# Same as above: positional path instead of --entry
npx lfify ./src
# Convert a single file
npx lfify src/app.js
npx lfify --entry src/app.js
# Use a custom config file
npx lfify --config ./custom-config.json
# Show detailed progress logs
npx lfify --log-level > warnDefault behavior
When no config file is found and no CLI options are provided, lfify uses sensible defaults:
- include:
**/*(all files) - exclude:
node_modules/**,.git/**,dist/**,build/**,coverage/** - logLevel:
error
Priority
CLI options take precedence over config file values:
- CLI arguments (highest)
- Config file
- Default values (lowest)
Development
Prerequisites
- Node.js 18 or higher
- npm
Setup
Clone the repository:
git clone https://github.com/GyeongHoKim/lfify.gitInstall dependencies:
npm installTesting
npm testLinting
npm run lintContributing
- Fork the repository
- Create a new branch
- Make your changes
- Run
npm run lintto check your code - Run
npm testto check your code - Submit a pull request
Issues and Support
If you have any issues or feedback, please open an issue on the GitHub repository.
