Closed Torr6River closed 5 years ago
This is a funny one. We actually do have a check for this.
But for some reason stdin()
returns a \n
which doesn't count as an empty message.
I guess checking if input
is a line-break only would work but the nicer way would be to figure out why this used to work (I guess... did it?) and now apparently input is a \n
and it stopped working.
Ideas? @byCedric @marionebl
Oh wow, nice find! 😄 Ok, so apparently it's expected behavior from Sindre's package get-stdin
. The only way I can come up with another solution is the .trim()
or even .trimEnd()
method. It also trims line breaks, but I'm not sure if it trims too much or has an impact on some rules.
value | trim | trimEnd |
---|---|---|
'\n' |
'' |
'' |
' \n ' |
'' |
'' |
'foo: bar\n' |
'foo: bar' |
'foo: bar' |
'foo: bar\n\ntest\n |
'foo: bar\n\ntest' |
'foo: bar\n\ntest' |
Haha, funny. Didn't come up with checking get-stdn
. Nice!
Checking that linked issue, how would 'foo\nbar\n\n'
be treated in your examples?
git commit --allow-empty -m ""
Expected Behavior
error message on the empty commit AND validate as normal
Current Behavior
Steps to Reproduce (for bugs)
Context
Your Environment
Mac OS High Sierra
commitlint --version
git --version
node --version