Skip to content

Commit 68fafbe

Browse files
committed
Merge branch 'release/v0.10.0'
2 parents aa98c08 + cbde480 commit 68fafbe

10 files changed

+3430
-1982
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ branches:
77
language: node_js
88
node_js:
99
- stable
10+
- 10
1011
- 9
1112
- 8
1213
sudo: false

index.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
55
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
66

77
var util = _interopDefault(require('util'));
8-
var _console = _interopDefault(require('console'));
8+
var console = require('console');
99
var termNG = _interopDefault(require('term-ng'));
1010
var chalk = _interopDefault(require('chalk'));
1111
var sparkles = _interopDefault(require('sparkles'));
@@ -52,7 +52,7 @@ const consoleFactory = function (options = {}) {
5252

5353
const prefixFormatter = (pfix => pfix ? () => `[${pfix}] ` : () => '')(prefix);
5454

55-
return Object.assign(Object.create(_console.Console), {
55+
return Object.assign(new console.Console(sOut, sErr), {
5656
_stdout: sOut,
5757
_stderr: sErr,
5858
threshold: verbosity ? verbosity : 3,
@@ -179,14 +179,14 @@ const consoleFactory = function (options = {}) {
179179
sOut.write(format(inspect(obj, options)));
180180
},
181181

182-
pretty(obj, depth = 0) {
182+
pretty(obj, depth = 0, color = true) {
183183
sOut.write(format('Content: %s\n', inspect(obj, {
184184
depth,
185-
colors: termNG.color.basic
186-
}).slice(0, -1).replace(/^{/, 'Object\n ').replace(/^\[/, 'Array\n ').replace(/^(\w+) {/, '$1').replace(/:/g, ' ▸').replace(/,\n/g, '\n')));
185+
colors: color && termNG.color.basic
186+
}).slice(0, -1).replace(/^{/, 'Object\n ').replace(/^\[/, 'Array\n ').replace(/^(\w+) {/, '$1').replace(/(\w+):/g, '$1 ▸').replace(/,\n/g, '\n')));
187187
},
188188

189-
yargs(obj) {
189+
yargs(obj, color = true) {
190190
const parsed = {};
191191
Object.keys(obj).forEach(key_ => {
192192
const val = obj[key_];
@@ -211,15 +211,15 @@ const consoleFactory = function (options = {}) {
211211
}
212212
});
213213
sOut.write(format('Options (yargs):\n %s\n', inspect(parsed, {
214-
colors: termNG.color.basic
215-
}).slice(2, -1).replace(/:/g, ' ▸').replace(/,\n/g, '\n')));
214+
colors: color && termNG.color.basic
215+
}).slice(2, -1).replace(/(\w+):/g, '$1 ▸').replace(/,\n/g, '\n')));
216216
}
217217

218218
});
219219
};
220220

221221

222-
function console(options) {
222+
function console$1(options) {
223223
return consoleFactory(options);
224224
}
225225

@@ -229,6 +229,6 @@ function createConsole(options) {
229229

230230
const getVersion = level => metadata.version(level);
231231

232-
exports.console = console;
232+
exports.console = console$1;
233233
exports.createConsole = createConsole;
234234
exports.getVersion = getVersion;

index.mjs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import util from 'util';
2-
import _console from 'console';
2+
import { Console } from 'console';
33
import termNG from 'term-ng';
44
import chalk from 'chalk';
55
import sparkles from 'sparkles';
@@ -46,7 +46,7 @@ const consoleFactory = function (options = {}) {
4646

4747
const prefixFormatter = (pfix => pfix ? () => `[${pfix}] ` : () => '')(prefix);
4848

49-
return Object.assign(Object.create(_console.Console), {
49+
return Object.assign(new Console(sOut, sErr), {
5050
_stdout: sOut,
5151
_stderr: sErr,
5252
threshold: verbosity ? verbosity : 3,
@@ -173,14 +173,14 @@ const consoleFactory = function (options = {}) {
173173
sOut.write(format(inspect(obj, options)));
174174
},
175175

176-
pretty(obj, depth = 0) {
176+
pretty(obj, depth = 0, color = true) {
177177
sOut.write(format('Content: %s\n', inspect(obj, {
178178
depth,
179-
colors: termNG.color.basic
180-
}).slice(0, -1).replace(/^{/, 'Object\n ').replace(/^\[/, 'Array\n ').replace(/^(\w+) {/, '$1').replace(/:/g, ' ▸').replace(/,\n/g, '\n')));
179+
colors: color && termNG.color.basic
180+
}).slice(0, -1).replace(/^{/, 'Object\n ').replace(/^\[/, 'Array\n ').replace(/^(\w+) {/, '$1').replace(/(\w+):/g, '$1 ▸').replace(/,\n/g, '\n')));
181181
},
182182

183-
yargs(obj) {
183+
yargs(obj, color = true) {
184184
const parsed = {};
185185
Object.keys(obj).forEach(key_ => {
186186
const val = obj[key_];
@@ -205,8 +205,8 @@ const consoleFactory = function (options = {}) {
205205
}
206206
});
207207
sOut.write(format('Options (yargs):\n %s\n', inspect(parsed, {
208-
colors: termNG.color.basic
209-
}).slice(2, -1).replace(/:/g, ' ▸').replace(/,\n/g, '\n')));
208+
colors: color && termNG.color.basic
209+
}).slice(2, -1).replace(/(\w+):/g, '$1 ▸').replace(/,\n/g, '\n')));
210210
}
211211

212212
});

0 commit comments

Comments
 (0)