diff --git a/README.md b/README.md index 3d18d89..72c839c 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,9 @@ An elegant console reporter, borrowed from [Yarn](https://yarnpkg.com). ## Introduction -Pretty console output makes developers happy and Yarn is doing a nice job. Yurnalist takes the internal console reporter code from Yarn and makes it available for use in other Node.js applications. +Pretty console output makes developers happy and Yarn is doing a nice job. +Yurnalist takes the internal console reporter code from Yarn and makes it +available for use in other Node.js applications. The current version is based on code from Yarn v1.13.0. @@ -80,7 +82,9 @@ Node >= 4 ## Examples -Examples showing different API functions are found in [/examples](/examples). You can run them directly with node >= 7.6 (because of async/await syntax). For older versions you could use the `--harmony` flag, or otherwise Babel. +Examples showing different API functions are found in [/examples](/examples). +You can run them directly with node >= 7.6 (because of async/await syntax). For +older versions you could use the `--harmony` flag, or otherwise Babel. To run the activity example: @@ -90,7 +94,9 @@ node examples/activity.js ## Configuration -A normal import gives you a reporter instance configured with defaults for easy use. If you want something else you can call `createReporter(options)` to give you an instance with different options. +A normal import gives you a reporter instance configured with defaults for easy +use. If you want something else you can call `createReporter(options)` to give +you an instance with different options. ### Options @@ -126,11 +132,26 @@ const defaults = { } ``` -The peekMemoryCounter is disabled by default. If you enable it, you'll have to call `reporter.close()` to stop its running timer. Otherwise your program will not exit. The memory counter can be used to display in the footer data. +The peekMemoryCounter is disabled by default. If you enable it, you'll have to +call `reporter.close()` to stop its running timer. Otherwise your program will +not exit. The memory counter can be used to display in the footer data. + +## Silent Mode and CI + +Silent mode can be set via the options passed to createReporter. It disables +output for various functions like `info`, `list`, `activity` and `progress`. The +output from `warning` and `error` messages is not silenced. + +Silent mode can also be enabled with the `YURNALIST_SILENT` environment +variable. + +In CI environments the output from `activity` and `progress` is disabled. ## API -The API still needs some documentation, but most methods are straightforward. In the meantime you can also look at the [examples](./examples) and possibly even the [tests](./__tests__). +The API still needs some documentation, but most methods are straightforward. In +the meantime you can also look at the [examples](./examples) and possibly even +the [tests](./__tests__). The following functions are available: @@ -142,10 +163,10 @@ The following functions are available: Pretty-prints the `thing`. -### list(key: string, items: Array, hints?: Object) +### list(key: string, items: Array, hints?: Object) -Generates a list of the provided items. Turns into a definition -list if `hints` are provided. Note that the `key` is not used. +Generates a list of the provided items. Turns into a definition list if `hints` +are provided. Note that the `key` is not used. Example of a simple list: @@ -184,7 +205,7 @@ report.list('dunno', someList, hints); ``` generates ``` -info My grocery list +info My grocery list - bananas for baking - tulips @@ -214,13 +235,18 @@ info My grocery list ## Language -Yarn uses a language file for certain messages. For example if you try to skip a required question, or when you pick an invalid item from a select. This language file is not yet exposed in the Yurnalist API. The only supported language is English, as it is in Yarn at the moment. +Yarn uses a language file for certain messages. For example if you try to skip a +required question, or when you pick an invalid item from a select. This language +file is not yet exposed in the Yurnalist API. The only supported language is +English, as it is in Yarn at the moment. -I plan to make this configurable so that you can define your own messages in your own language . +I plan to make this configurable so that you can define your own messages in +your own language . ## Emojis -You can use Emojis in your output. Yurnalist should disable them if they are not allowed in the application environment. +You can use Emojis in your output. Yurnalist should disable them if they are not +allowed in the application environment. Check: @@ -229,4 +255,6 @@ Check: ## Credits -Of course ❤️ and credits to all the contributers of [Yarn](https://yarnpkg.com). The ease with which I was able to extract this module from their codebase is proving some awesome engineering skills. +Of course ❤️ and credits to all the contributers of [Yarn](https://yarnpkg.com). +The ease with which I was able to extract this module from their codebase is +proving some awesome engineering skills. diff --git a/src/reporters/console/console-reporter.js b/src/reporters/console/console-reporter.js index c5bb5a0..4fb3460 100644 --- a/src/reporters/console/console-reporter.js +++ b/src/reporters/console/console-reporter.js @@ -19,6 +19,7 @@ import {clearLine} from './util.js'; import {removeSuffix} from '../../util/misc.js'; import {sortTrees, recurseTree, getFormattedOutput} from './helpers/tree-helper.js'; import inquirer from 'inquirer'; +import isCI from 'is-ci'; const {inspect} = require('util'); const readline = require('readline'); @@ -321,7 +322,7 @@ export default class ConsoleReporter extends BaseReporter { } activity(): ReporterSpinner { - if (!this.isTTY) { + if (!this.isTTY || this.isSilent || isCI) { return { tick() {}, end() {}, @@ -411,7 +412,7 @@ export default class ConsoleReporter extends BaseReporter { }; } - if (!this.isTTY) { + if (!this.isTTY || this.isSilent || isCI) { return function() { // TODO what should the behaviour here be? we could buffer progress messages maybe };