Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/okunishinishi/node-colorprint
Print ansi-colored message with Node.js
https://github.com/okunishinishi/node-colorprint
Last synced: 2 months ago
JSON representation
Print ansi-colored message with Node.js
- Host: GitHub
- URL: https://github.com/okunishinishi/node-colorprint
- Owner: okunishinishi
- License: mit
- Created: 2015-07-11T08:43:53.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-01-03T16:44:21.000Z (about 2 years ago)
- Last Synced: 2024-08-11T08:08:50.970Z (5 months ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/colorprint
- Size: 802 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
colorprint
==========[![Build Status][bd_travis_shield_url]][bd_travis_url]
[![npm Version][bd_npm_shield_url]][bd_npm_url]
[![JS Standard][bd_standard_shield_url]][bd_standard_url][bd_repo_url]: https://github.com/okunishinishi/node-colorprint
[bd_travis_url]: http://travis-ci.org/okunishinishi/node-colorprint
[bd_travis_shield_url]: http://img.shields.io/travis/okunishinishi/node-colorprint.svg?style=flat
[bd_travis_com_url]: http://travis-ci.com/okunishinishi/node-colorprint
[bd_travis_com_shield_url]: https://api.travis-ci.com/okunishinishi/node-colorprint.svg?token=
[bd_license_url]: https://github.com/okunishinishi/node-colorprint/blob/master/LICENSE
[bd_codeclimate_url]: http://codeclimate.com/github/okunishinishi/node-colorprint
[bd_codeclimate_shield_url]: http://img.shields.io/codeclimate/github/okunishinishi/node-colorprint.svg?style=flat
[bd_codeclimate_coverage_shield_url]: http://img.shields.io/codeclimate/coverage/github/okunishinishi/node-colorprint.svg?style=flat
[bd_gemnasium_url]: https://gemnasium.com/okunishinishi/node-colorprint
[bd_gemnasium_shield_url]: https://gemnasium.com/okunishinishi/node-colorprint.svg
[bd_npm_url]: http://www.npmjs.org/package/colorprint
[bd_npm_shield_url]: http://img.shields.io/npm/v/colorprint.svg?style=flat
[bd_standard_url]: http://standardjs.com/
[bd_standard_shield_url]: https://img.shields.io/badge/code%20style-standard-brightgreen.svgPrint ansi-colored message to stdout/stderr.
Installation
-----```bash
npm install colorprint --save
```Usage
-------```javascript
"use strict";const colorpint = require('colorpint')
colorpint.notice('This is NOTICE') //Pipe to stdout with magenta color.
colorpint.info('This is INFO') //Pipe to stdout with green color.
colorpint.debug('This is DEBUG') //Pipe to stdout with color.
colorpint.trace('This is TRACE') //Pipe to stdout with white color.
colorpint.warn('This is WARN') //Pipe to stdout with yellow color.
colorpint.error('This is ERROR') //Pipe to stderr with red color.
colorpint.fatal('This is FATAL') //Pipe to stderr with bgRed color.```
Using via CIL
-------### Install globally
```
$ npm install colorprint -g
```### From Command Line
```bash
#!/bin/bashcolorpint notice "This is NOTICE from CLI" # Pipe to stdout with magenta color.
colorpint info "This is INFO from CLI" # Pipe to stdout with green color.
colorpint debug "This is DEBUG from CLI" # Pipe to stdout with color.
colorpint trace "This is TRACE from CLI" # Pipe to stdout with white color.
colorpint warn "This is WARN from CLI" # Pipe to stdout with yellow color.
colorpint error "This is ERROR from CLI" # Pipe to stderr with red color.
colorpint fatal "This is FATAL from CLI" # Pipe to stderr with bgRed color.```
Customizing
--------### Customize the whole module.
```javascript
"use strict";const colorprint = require('colorprint');
colorprint.PREFIX='Yeah!';
colorprint.INFO_COLOR='blue';
colorprint.info('This will be blue with prefix.');```
### Create new context to customize.
```javascript
"use strict";const Colorprint = require('colorprint/lib/colorprint');
let colorprint = new Colorprint({
PREFIX: '[Foo]',
INFO_COLOR: 'blue'
});
colorprint.info('This will be blue with prefix.');```
colorprint is using [cli-color](https://github.com/medikoo/cli-color) for coloring and you can see [available colors here](https://github.com/medikoo/cli-color#colors).
License
-------
This software is released under the [MIT License](https://github.com/okunishinishi/node-colorprint/blob/master/LICENSE).