New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix CLI to avoid waiting for stdin without any input and avoid different outputs #7131
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
@@ -183,24 +183,22 @@ describe('buildCLI', () => { | |||
}); | |||
|
|||
describe('CLI', () => { | |||
beforeAll(() => { | |||
beforeEach(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[note] To avoid effects on each it
.
expect(process.stdout.write).toHaveBeenCalledTimes(0); | ||
expect(process.stderr.write).toHaveBeenCalledTimes(0); | ||
expect(process.stdout.write).not.toHaveBeenCalled(); | ||
expect(process.stderr.write).not.toHaveBeenCalled(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[note] To clarify the difference from toHaveBeenCalledWith(0)
.
This commit changes the following: 1. To avoid waiting for stdin without any input. For example, just running the `stylelint` command immediately exits, instead of waiting. I believe this behavior is more user-friendly. 2. To avoid different outputs on empty files and empty stdin. This is achieved by allowing an empty string input (`''`) from stdin. See the example below: ```sh # code is undefined bin/stylelint.mjs # code is '' echo -n '' | bin/stylelint.mjs ``` See also [`process.stdin.isTTY`](https://nodejs.org/api/tty.html#readstreamistty).
1e305db
to
329c6e1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great to see consistent behaviour for empty files and std.
Changed: CLI to avoid waiting for stdin without any input
We used to show help on npx stylelint
. Did we intentionally change it to wait for stdin? If not, then it's a regression, and we can change the entry to patch/fixed and drop the migration guide entry.
I found out the reason. This bug was mixed in when I removed the I'll update the changelog and migration guide. Thanks for pointing it out! |
FYI. This regression happened with $ npm i -s 'stylelint@14.10.0' && npx stylelint
# waiting for stdin... $ npm i -s 'stylelint@14.9.1' && npx stylelint | grep 'Usage:'
Usage: stylelint [input] [options] |
Fixed via 88bb9b4. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor suggestion for the changelog entry. Otherwise, LGTM thank you!
Co-authored-by: Richard Hallows <jeddy3@users.noreply.github.com>
Thanks for the review! I've addressed the review on the changelog. |
…ent outputs (#7131) This commit changes the following: 1. To avoid waiting for stdin without any input. For example, just running the `stylelint` command immediately exits, instead of waiting. I believe this behavior is more user-friendly. 2. To avoid different outputs on empty files and empty stdin. This is achieved by allowing an empty string input (`''`) from stdin. See the example below: ```sh # code is undefined bin/stylelint.mjs # code is '' echo -n '' | bin/stylelint.mjs ``` Co-authored-by: Richard Hallows <jeddy3@users.noreply.github.com>
…ent outputs (#7131) This commit changes the following: 1. To avoid waiting for stdin without any input. For example, just running the `stylelint` command immediately exits, instead of waiting. I believe this behavior is more user-friendly. 2. To avoid different outputs on empty files and empty stdin. This is achieved by allowing an empty string input (`''`) from stdin. See the example below: ```sh # code is undefined bin/stylelint.mjs # code is '' echo -n '' | bin/stylelint.mjs ``` Co-authored-by: Richard Hallows <jeddy3@users.noreply.github.com>
…ent outputs (#7131) This commit changes the following: 1. To avoid waiting for stdin without any input. For example, just running the `stylelint` command immediately exits, instead of waiting. I believe this behavior is more user-friendly. 2. To avoid different outputs on empty files and empty stdin. This is achieved by allowing an empty string input (`''`) from stdin. See the example below: ```sh # code is undefined bin/stylelint.mjs # code is '' echo -n '' | bin/stylelint.mjs ``` Co-authored-by: Richard Hallows <jeddy3@users.noreply.github.com>
…ent outputs (#7131) This commit changes the following: 1. To avoid waiting for stdin without any input. For example, just running the `stylelint` command immediately exits, instead of waiting. I believe this behavior is more user-friendly. 2. To avoid different outputs on empty files and empty stdin. This is achieved by allowing an empty string input (`''`) from stdin. See the example below: ```sh # code is undefined bin/stylelint.mjs # code is '' echo -n '' | bin/stylelint.mjs ``` Co-authored-by: Richard Hallows <jeddy3@users.noreply.github.com>
Closes #3401
This commit changes the following:
stylelint
commandimmediately exits, instead of waiting. I believe this behavior is more user-friendly.
string input (
''
) from stdin. See the example below:See also
process.stdin.isTTY
.