Skip to content
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

Don't use stdin unless --stdin flag is specified #17

Merged
merged 2 commits into from
Sep 13, 2021

Conversation

msabramo
Copy link
Contributor

@msabramo msabramo commented Sep 12, 2021

Before:

$ echo '' | FORCE_COLOR=1 node cli.js green 'this is a test'
Invalid style: this is a test

After:

$ echo '' | FORCE_COLOR=1 node cli.js green 'this is a test'
this is a test

$ echo '' | FORCE_COLOR=1 node cli.js green 'this is a test' | cat
this is a test

$ echo 'text from stdin' | node cli.js --stdin green
text from stdin

Fixes #11

Before:
-------

```
$ echo '' | FORCE_COLOR=1 node cli.js green 'this is a test'
Invalid style: this is a test
```

After:

```
$ echo '' | FORCE_COLOR=1 node cli.js green 'this is a test'
this is a test

$ echo '' | FORCE_COLOR=1 node cli.js green 'this is a test' | cat
this is a test

$ echo 'text from stdin' | node cli.js --stdin green
text from stdin
```

Fixes: chalkGH-11
cli.js Show resolved Hide resolved
cli.js Outdated Show resolved Hide resolved
cli.js Outdated Show resolved Hide resolved
@sindresorhus
Copy link
Member

You also need to update the readme.

1. Put `--stdin` stuff after `--template` in two places.
2. `cli.flags.stdin !== true` => `!cli.flags.stdin`
3. Update `readme.md`
@msabramo
Copy link
Contributor Author

Thanks, @sindresorhus! I made the updates you requested in 915e1a6. If you want other changes or want me to squash, let me know.

@sindresorhus sindresorhus changed the title Don't use stdin unless --stdin specfied Don't use stdin unless --stdin flag is specified Sep 13, 2021
@sindresorhus sindresorhus merged commit 14a98bc into chalk:main Sep 13, 2021
@msabramo msabramo deleted the GH-11 branch September 13, 2021 14:51
@msabramo msabramo restored the GH-11 branch September 13, 2021 14:51
msabramo added a commit to msabramo/chalk-cli that referenced this pull request Sep 13, 2021
While editing `readme.md` for chalkGH-17, I noticed that VS Code was
formatting lines with tabs for indentation and that it looked bad in the
diffs, because it wasn't matching the existing lines.

Ths updates `.editconfig` so that it uses spaces for indentation in
Markdown files, which seems to match what has been used.
@msabramo msabramo mentioned this pull request Sep 13, 2021
msabramo added a commit to msabramo/chalk-cli that referenced this pull request Sep 13, 2021
While editing `readme.md` for chalkGH-17, I noticed that VS Code was
formatting lines with tabs for indentation and that it looked bad in the
diffs, because it wasn't matching the existing lines.

Ths updates `.editconfig` so that it uses spaces for indentation in
Markdown files, which seems to match what has been used.

```
$ git diff readme.md
diff --git a/readme.md b/readme.md
index 5a21992..e0f2c4a 100644
--- a/readme.md
+++ b/readme.md
@@ -24,6 +24,8 @@ $ chalk --help
   Options
     --template, -t  Style template. The `~` character negates the style.
     --demo          Demo of all Chalk styles.
+               --fake-flag1    Fake flag added BEFORE updating .editorconfig to use spaces for Markdown files
+    --fake-flag2    Fake flag added AFTER updating .editorconfig to use spaces for Markdown files

   Examples
     $ chalk red bold 'Unicorns & Rainbows'
```
msabramo added a commit to msabramo/chalk-cli that referenced this pull request Sep 13, 2021
While editing `readme.md` for chalkGH-17, I noticed that VS Code was
formatting lines with tabs for indentation and that it looked bad in the
diffs, because it wasn't matching the existing lines.

Ths updates `.editconfig` so that it uses spaces for indentation in
Markdown files, which seems to match what has been used.

```
$ git diff readme.md
diff --git a/readme.md b/readme.md
index 5a21992..e0f2c4a 100644
--- a/readme.md
+++ b/readme.md
@@ -24,6 +24,8 @@ $ chalk --help
   Options
     --template, -t  Style template. The `~` character negates the style.
     --demo          Demo of all Chalk styles.
+               --fake-flag1    Fake flag added BEFORE updating .editorconfig to use spaces for Markdown files
+    --fake-flag2    Fake flag added AFTER updating .editorconfig to use spaces for Markdown files

   Examples
     $ chalk red bold 'Unicorns & Rainbows'
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using in non-tty environment giving errors
3 participants