@graphene-system/cli-reporter v1.0.6
@graphene-system/cli-reporter
Formatted console output reporter for the Graphene CLI.
🚀 Getting started
To install @graphene-system/cli-reporter
in your project, you will need to run
the following command using Yarn:
yarn add @graphene-system/cli-reporter
If you prefer npm, use the following command instead:
npm install -S @graphene-system/cli-reporter
You can use the @graphene-system/cli-reporter
module in both your JavaScript
and Typescript projects, typings are already built into the package.
For both languages, you can import and use this module by doing the following in your code:
// ECMAScript Modules
import { reporter } from '@graphene-system/cli-reporter';
// CommonJS Modules
const { reporter } = require('@graphene-system/cli-reporter');
Now you're ready to start sending formatted output to the console!
⚙️ Usage
Pre-formatted messages
The package provides 6 methods that provide pre-formatted console outputs, like this:
// Unformatted output with no tags.
reporter.log('My normal message');
// Red "ERROR" tag before message output.
reporter.error('My error message');
// Blue "INFO" tag before message output.
reporter.info('My information message');
// Green "SUCCESS" tag before message output.
reporter.success('My success message');
// Yellow "WARNING" tag before message output.
reporter.warning('My warning message');
// Default colored bold output with no tags.
reporter.header('My bold header');
Custom-tagged messages
You can build your own tagged messages, like this:
const tag = 'My tag';
const message = 'This a custom message!';
const color = 'bgMagenta';
reporter.custom(tag, message, color);
Make sure to use a background color supported by Chalk in order to prevent incorrect tag construction.
Error output
If you need to print an error, with or without a stacktrace (managed by the
debug
flag), you can use the stack
helper method, like this:
// Error to print
const myError = new Error('Oh, no!');
// With a stacktrace
reporter.stack(myError);
// Without a stacktrace
reporter.stack(myError, false);
The reporter will automatically format the stacktrace to have colored tags.
🙌 Contributing
We're always looking for new contributors to help us fix bugs, create new features, or help us improve the project documentation. If you're interested, please, check out our Contributing Guide!
📝 License
The module @graphene-system/cli-reporter
is licensed under the
Apache 2.0 License.