simple-output
Advanced tools
Comparing version 2.2.1 to 3.0.0
61
index.js
@@ -1,5 +0,17 @@ | ||
const symbols = require('log-symbols'); | ||
const chalk = require('chalk'); | ||
/* istanbul ignore next */ | ||
const isWindows = () => | ||
(process.platform === 'win32' && process.env.TERM !== 'xterm-256color') || | ||
process.env.SIMPLE_OUTPUT_NO_ICONS; | ||
/* istanbul ignore next */ | ||
const hasBasicColorSupport = () => ( | ||
/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test( | ||
process.env.TERM) || process.env.COLORTERM | ||
); | ||
const colors = () => | ||
process.env.FORCE_COLOR === 'true' || | ||
(hasBasicColorSupport() && !process.env.CI); | ||
// -- | ||
@@ -9,35 +21,38 @@ | ||
function success(msg) { | ||
module.exports.stdout.write(symbols.success + ' ' + msg + '\n'); | ||
const symbol = isWindows() ? '√' : '✔'; | ||
const prefix = colors() ? `[32m${symbol}[39m` : symbol; | ||
module.exports.stdout.write(`${prefix} ${msg}\n`); | ||
} | ||
function error(msg) { | ||
module.exports.stderr.write(symbols.error + ' ' + msg + '\n'); | ||
function info(msg) { | ||
const symbol = isWindows() ? 'i' : 'ℹ'; | ||
const prefix = colors() ? `[34m${symbol}[39m` : symbol; | ||
module.exports.stdout.write(`${prefix} ${msg}\n`); | ||
} | ||
function info(msg) { | ||
module.exports.stdout.write(symbols.info + ' ' + msg + '\n'); | ||
function warn(msg) { | ||
const symbol = isWindows() ? '‼' : '⚠'; | ||
const prefix = colors() ? `[33m${symbol}[39m` : symbol; | ||
module.exports.stdout.write(`${prefix} ${msg}\n`); | ||
} | ||
function message(msg) { | ||
module.exports.stdout.write(msg + '\n'); | ||
function error(msg) { | ||
const symbol = isWindows() ? '×' : '✖'; | ||
const prefix = colors() ? `[31m${symbol}[39m` : symbol; | ||
module.exports.stderr.write(`${prefix} ${msg}\n`); | ||
} | ||
function hint(msg) { | ||
module.exports.stdout.write(chalk.dim(msg) + '\n'); | ||
function node(msg) { | ||
const symbol = isWindows() ? '*' : '⬢'; | ||
const prefix = colors() ? `[32m${symbol}[39m` : symbol; | ||
module.exports.stdout.write(`${prefix} ${msg}\n`); | ||
} | ||
function warn(msg) { | ||
module.exports.stdout.write(symbols.warning + ' ' + msg + '\n'); | ||
function message(msg) { | ||
module.exports.stdout.write(`${msg}\n`); | ||
} | ||
function node(msg) { | ||
if (process.platform === 'win32') { | ||
return success(msg); | ||
} | ||
const icon = '⬢'; | ||
const matchOperatorsRegex = /[|\\{}()[\]^$+*?.-]/g; | ||
const node = chalk.green( | ||
icon.replace(matchOperatorsRegex, '\\$&') | ||
); | ||
module.exports.stdout.write(node + ' ' + msg + '\n'); | ||
function hint(msg) { | ||
const styledMsg = colors() ? `[2m${msg}[22m` : msg; | ||
module.exports.stdout.write(`${styledMsg}\n`); | ||
} | ||
@@ -44,0 +59,0 @@ |
{ | ||
"name": "simple-output", | ||
"version": "2.2.1", | ||
"version": "3.0.0", | ||
"main": "index.js", | ||
@@ -11,3 +11,3 @@ "files": [ | ||
}, | ||
"description": "Output messages to stdout/stderr", | ||
"description": "Output messages to stdout/stderr, zero deps.", | ||
"homepage": "https://github.com/ruyadorno/simple-output", | ||
@@ -17,3 +17,4 @@ "bugs": "https://github.com/ruyadorno/simple-output/issues", | ||
"name": "Ruy Adorno", | ||
"url": "http://ruyadorno.com" | ||
"url": "http://ruyadorno.com", | ||
"twitter": "ruyadorno" | ||
}, | ||
@@ -35,12 +36,10 @@ "repository": { | ||
"devDependencies": { | ||
"jshint": "^2.12.0" | ||
"jshint": "^2.13.3", | ||
"tap": "^15.1.6" | ||
}, | ||
"dependencies": { | ||
"chalk": "^4.1.0", | ||
"log-symbols": "^4.0.0" | ||
}, | ||
"scripts": { | ||
"pretest": "jshint index.js test.js", | ||
"test": "node test.js" | ||
"test": "tap test.js", | ||
"snap": "tap -S test.js" | ||
} | ||
} |
@@ -7,4 +7,12 @@ # simple-output | ||
Pretty output messages to stdout/stderr | ||
Pretty output messages to stdout/stderr with no extra dependencies. | ||
<div align="center"> | ||
<br> | ||
<br> | ||
<img alt="render examples" width="350" src="https://user-images.githubusercontent.com/220900/150694210-7284e3fe-e713-42a4-98b9-f6d42dad9ac1.png"> | ||
<br> | ||
<br> | ||
</div> | ||
## Getting Started | ||
@@ -24,8 +32,8 @@ Install the module with: `npm install simple-output` | ||
- success(msg) | ||
- error(msg) | ||
- info(msg) | ||
- message(msg) | ||
- hint(msg) | ||
- node(msg) | ||
- warn(msg) | ||
- error(msg) | ||
- node(msg) prints a green hexagon icon (on supported platforms) along with msg | ||
- message(msg) prints msg, no icon associated with it | ||
- hint(msg) useful if you want to dim some of the output | ||
@@ -69,3 +77,3 @@ ## Testing | ||
[MIT](LICENSE) © 2021 [Ruy Adorno](http://ruyadorno.com) | ||
[MIT](LICENSE) © 2022 [Ruy Adorno](http://ruyadorno.com) | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5790
0
57
77
2
- Removedchalk@^4.1.0
- Removedlog-symbols@^4.0.0
- Removedansi-styles@4.3.0(transitive)
- Removedchalk@4.1.2(transitive)
- Removedcolor-convert@2.0.1(transitive)
- Removedcolor-name@1.1.4(transitive)
- Removedhas-flag@4.0.0(transitive)
- Removedis-unicode-supported@0.1.0(transitive)
- Removedlog-symbols@4.1.0(transitive)
- Removedsupports-color@7.2.0(transitive)