https://github.com/marckassay/endofline
EndOfLine is a PowerShell module that automates conversion of end-of-line (EOL) characters in files.
https://github.com/marckassay/endofline
automation convert eol line linux normalize powershell unix windows
Last synced: 4 months ago
JSON representation
EndOfLine is a PowerShell module that automates conversion of end-of-line (EOL) characters in files.
- Host: GitHub
- URL: https://github.com/marckassay/endofline
- Owner: marckassay
- License: mit
- Created: 2017-08-13T03:35:58.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2022-03-14T22:08:59.000Z (over 3 years ago)
- Last Synced: 2025-04-30T22:51:35.063Z (6 months ago)
- Topics: automation, convert, eol, line, linux, normalize, powershell, unix, windows
- Language: PowerShell
- Homepage:
- Size: 49.8 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# EndOfLine
Objective of this module is conversion of end-of-line (EOL) characters in UTF-8 files: CRLF to LF or LF to CRLF
[](https://github.com/marckassay/EndOfLine/blob/master/LICENSE) [](https://www.powershellgallery.com/packages/EndOfLine/)
## Features
* Imports `.gitignore` file for exclusion of files and directories, if there is a file. You can use `SkipIgnoreFile` switch to prevent importing that file. And you can switch `Exclude` to add additional items to be excluded.
* Simulate what will happen via `WhatIf` switch
* Outputs a report on all files. The `Verbose` switch can be used too.## Caveat
* Please use the `WhatIf` switch parameter to perform a 'dry-run' on what files will be modified.
* Files are expected to be encoded in UTF-8. If encoded in anything else it will not be modified.## Instructions
To install, run the following command in PowerShell.
```powershell
$ Install-Module EndOfLine
```This module imports 'Encoding' by [Chris Kuech](https://github.com/chriskuech).
[](https://www.powershellgallery.com/packages/Encoding)
## Usage
### ConvertTo-LF
```powershell
ConvertTo-LF [-Path] [[-Exclude] ]
[-SkipIgnoreFile] [-ExportReportData] [-WhatIf] []
```Converts CRLF to LF characters.
This function will recursively read all files within the `Path` unless excluded by `.gitignore` file. If a file is not excluded it is read to see if the current EOL character is the same as requested. If so it will not modify the file. And if the file is encoded other then UTF-8, it will not be modified.Example using the `WhatIf`, and `Verbose` switch.
```powershell
$ ConvertTo-LF -Path C:\repos\AiT -WhatIf -Verbose
```For this example, if you agree when prompted files will be modified without import of `.gitignore` file.
```powershell
$ ConvertTo-LF -Path C:\repos\AiT -SkipIgnoreFile
```If omitting `gitignore` file, it would be good to exclude modules too.
```powershell
$ ConvertTo-LF -Path C:\repos\AiT -Exclude .\node_modules\, .\out\ -SkipIgnoreFile
```If you agree when prompted, files will be modified with import of `.gitignore` file if found.
```powershell
$ ConvertTo-LF -Path C:\repos\AiT
```### ConvertTo-CRLF
```powershell
ConvertTo-CRLF [-Path] [[-Exclude] ]
[-SkipIgnoreFile] [-ExportReportData] [-WhatIf] []
```Converts LF to CRLF characters.
Besides the characters that will be replaced, all things that apply in `ConvertTo-LF` apply to this function too.