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

✨ Use color output automatically if terminal supports it #19

Merged
merged 1 commit into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ $ graphql-schema-diff --help
--fail-on-dangerous-changes Exit with error on dangerous changes
--fail-on-breaking-changes Exit with error on breaking changes
--fail-on-all-changes Exit with error on all changes
--use-colors Use colors for diff terminal output
--create-html-output Creates an HTML file containing the diff
--html-output-directory Directory where the HTML file should be stored (Default: './schemaDiff')
--header, -H Header to send to all remote schema sources
Expand Down
4 changes: 2 additions & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const cli = meow(
--fail-on-dangerous-changes Exit with error on dangerous changes
--fail-on-breaking-changes \t Exit with error on breaking changes
--fail-on-all-changes \t Exit with error on all changes
--use-colors \t\t Use colors for diff terminal output
--create-html-output \t Creates an HTML file containing the diff
--html-output-directory \t Directory where the HTML file should be stored (Default: './schemaDiff')
--header, -H \t\t Header to send to all remote schema sources
Expand All @@ -37,6 +36,7 @@ const cli = meow(
failOnAllChanges: {
type: "boolean",
},
// Deprecated: chalk.supportsColor should be used instead
useColors: {
type: "boolean",
},
Expand Down Expand Up @@ -134,7 +134,7 @@ getDiff(leftSchemaLocation, rightSchemaLocation, {
const hasBreakingChanges = result.breakingChanges.length !== 0;
const hasDangerousChanges = result.dangerousChanges.length !== 0;

if (cli.flags.useColors) {
if (cli.flags.useColors || chalk.supportsColor) {
console.log(result.diff);
} else {
console.log(result.diffNoColor);
Expand Down