Hello, I am presented with this error when calling the script "commitmsg ":"commitlint -e $GIT_PARAMS".
I do not know if any other configuration is required that I do not know.
I hope you can help me, and thank you very much in advance.

Reading the paths in the error message I guess you are on a Windows machine, right?
Could you try with commitlint -e %GIT_PARAMS%?
Hi, yes...
Still gives the same error.

I also tried with .git/COMMIT_EDITMSG.

I put a console.log inrequire-from-string.

And this is my commitlint.config.js file:

I deleted the file commitlint.config.js and created it manually without echo "module.exports = {extends: ['@commitlint/config-angular']};" > commitlint.config.js and eliminated the error, it worked.

However, I do not know what happens with the $GIT_PARAMS variable in windows.
It seems that there are problems using echo in powershell. Add this strange character?
With cmd it generates the file in this way:
echo module.exports = {extends: ['@commitlint/config-angular']}; > commitlint.config.js
And in bash it also works well.
The echo ... command is indeed only tested on bash.
I do not have access to win32 machines very often, so this is hard to test for me.
$GIT_PARAMS is intended to be used with husky. If you do not plan to use husky, just
commitlint -e
should be sufficient.
Yes I am using husky.
I leave this issue open?
For my part I will investigate to see what solution can be given to the use of the variable $GIT_PARAMS on Windows.
Thank you very much @marionebl
Yes, let's leave this open for now. We should check how to pass the path to the git commit edit message from husky to commitlint in a cross-platform compatible manner.
Also failed with this error in git bash on windows
"commitmsg": "commitlint -e" works for me
I still get the same error and "commitmsg": "commitlint -e .git/COMMIT_EDITMSG" works for me.
System: Window 7 x64
Node: 8.9.0
@SangKa: Does commitlint -e %GIT_PARAMS% work for you?
Unfortunately no, so I got here.
Okay, we'll have to implement a rather grungy fix for this, along the lines of
function normalizeEdit(edit) {
if (typeof edit === 'boolean') {
return edit;
}
if (edit === '$GIT_PARARMS' || edit === '%GIT_PARAMS%') {
if (!'GIT_PARAMS' in process.env) {
throw new Error(`Received ${edit} as value for -e | --edit, but GIT_PARAMS is not available globally.`);
}
return process.env.GIT_PARAMS;
}
return edit;
}
commitlint -e %GIT_PARAMS% works fine on Windows
commitlint -e works for both Windows and Mac
echo with redirection in Powershell. It's a feature - Powershell by default encodes strings in UTF16-LE. That is why you're getting spaces after each letter, and commitlint doesn't parse the config. Type it out by hand, or use the powershell-specific command:echo "module.exports = {extends: ['@commitlint/config-angular']};" | Out-File commitlint.config.js -Encoding utf8
cross-env in some way to pass husky's args to commitlint? Not sure how though...For what it's worth, %GIT_PARAMS% did work for me... Seems like cross-env might not be very useful in this case. 馃槥 We can access the params using process.env.GIT_PARAMS, for which we'll need to create a js file which spawns commitlint.
@kumarharsh Would you consider contributing a the fix for this as outlined via https://github.com/marionebl/commitlint/issues/103#issuecomment-346318328?
This would spare you from creating the js proxy file you mentioned and benefit other users down the line.
@marionbel - done!
Released via 5.2.3
Most helpful comment
Released via 5.2.3