commitlint: Windows line endings in config breaks CLI
Expected Behavior
If you have windows line endings in your config file, things should run as normal
Current Behavior
If you run the recommended echo command on Windows, it will break things as it will output Windows Line Endings.
Affected packages
- cli
- core
- prompt
- config-angular
Possible Solution
Add support for windows line endings in CLI
Steps to Reproduce (for bugs)
- Open Windows machine
- Run
echo "module.exports = {extends: ['@commitlint/config-angular']};" > commitlint.config.js - Run
commitlint
Context
Trying to setup commitlint in my project on Windows
Your Environment
| Executable | Version |
|---|---|
commitlint --version |
5.6.0 |
git --version |
git version 2.16.0.windows.2 |
node --version |
v8.9.1 |
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 16 (4 by maintainers)
On Windows, must through the notepad to open the file,Through the save as, change document character set!
for anyone still coming back after this long, i had the issue and i fixed it after 30m of head smashing
for windows then delete original and rename new (so it doesnt say used by another process)
The default config of encoding of VSCode in my machine is
UTF-16 LE. I met the same problem when executing scripts in the VSCode terminal (powershell) as @crutchcorn did. It was just solved after I changed the encoding toUTF-8.I fumbled around with the file (thanks for providing it!) and my tests indicate this is not caused by
\r\nline endings.It is the encoding, which is
UTF-16 LE. cosmiconfig assumes config files are encoded in UTF-8 and consequently feeds a string with invalid characters torequire-from-string.There is nothing
commitlintcan do to supportUTF-16 LEencoded files. I guess thecosmiconfigwon’t add support for other encodings, so your best bet will be to ensure config files areUTF-8encoded.