Skip to content

Commit 01c4214

Browse files
committed
Fix Object creation
1 parent e77cc68 commit 01c4214

File tree

8 files changed

+912
-1071
lines changed

8 files changed

+912
-1071
lines changed

index.js

+4-4
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,
@@ -219,7 +219,7 @@ const consoleFactory = function (options = {}) {
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

+2-2
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,

package-lock.json

+870-1,043
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+9-10
Original file line numberDiff line numberDiff line change
@@ -43,25 +43,25 @@
4343
},
4444
"homepage": "https://github.com/MarkGriffiths/verbosity#readme",
4545
"dependencies": {
46-
"@thebespokepixel/meta": "^0.2.2",
47-
"@thebespokepixel/time": "^0.4.0",
46+
"@thebespokepixel/meta": "^0.2.3",
47+
"@thebespokepixel/time": "^0.4.1",
4848
"chalk": "^2.4.1",
4949
"sparkles": "^1.0.1",
5050
"term-ng": "^0.8.1"
5151
},
5252
"devDependencies": {
53-
"@babel/core": "^7.0.0-beta.51",
54-
"@babel/preset-env": "^7.0.0-beta.51",
53+
"@babel/core": "^7.1.2",
54+
"@babel/preset-env": "^7.1.0",
5555
"ava": "^0.25.0",
56-
"documentation": "^8.0.0",
56+
"documentation": "^8.1.2",
5757
"documentation-theme-bespoke": "^0.4.3",
5858
"gulp": "^4.0.0",
59-
"gulp-better-rollup": "^3.2.1",
60-
"gulp-rename": "^1.3.0",
59+
"gulp-better-rollup": "^3.4.0",
60+
"gulp-rename": "^1.4.0",
6161
"gulp-strip-comments": "^2.5.2",
6262
"nyc": "^12.0.2",
63-
"rollup-plugin-babel": "^4.0.0-beta.5",
64-
"xo": "^0.21.1"
63+
"rollup-plugin-babel": "^4.0.3",
64+
"xo": "^0.23.0"
6565
},
6666
"xo": {
6767
"semicolon": false,
@@ -80,7 +80,6 @@
8080
"test/*.js"
8181
]
8282
},
83-
"buildNumber": 2,
8483
"badges": {
8584
"github": "MarkGriffiths",
8685
"npm": "thebespokepixel",

src/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import util from 'util'
66

7-
import _console from 'console'
7+
import {Console} from 'console'
88

99
import termNG from 'term-ng'
1010
import chalk from 'chalk'
@@ -64,7 +64,7 @@ const consoleFactory = function (options = {}) {
6464
() => ''
6565
)(prefix)
6666

67-
return Object.assign(Object.create(_console.Console), {
67+
return Object.assign(new Console(sOut, sErr), {
6868
_stdout: sOut,
6969
_stderr: sErr,
7070
threshold: verbosity ? verbosity : 3,

test/arguments.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ StreamProxy.setEncoding('utf8')
99

1010
const testConsole = createConsole({outStream: StreamProxy})
1111

12-
test(`Multiple arguments`, t => {
12+
test('Multiple arguments', t => {
1313
testConsole.log('this', 'has', 'many', 'arguments')
1414
const result = StreamProxy.read()
1515
t.is(result, 'this has many arguments\n')
1616
})
1717

18-
test(`Printf-like arguments`, t => {
18+
test('Printf-like arguments', t => {
1919
testConsole.log('this %s %s', 'has', 'printf', 'like', 'arguments')
2020
const result = StreamProxy.read()
2121
t.is(result, 'this has printf like arguments\n')

test/builtin.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'use strict'
2+
3+
import stream from 'stream'
4+
import test from 'ava'
5+
import {createConsole} from '..'
6+
7+
const StreamProxy = new stream.PassThrough()
8+
StreamProxy.setEncoding('utf8')
9+
10+
const testConsole = createConsole({outStream: StreamProxy})
11+
12+
test('Default count', t => {
13+
testConsole.count()
14+
testConsole.count()
15+
testConsole.count()
16+
const result = StreamProxy.read()
17+
t.is(result, `default: 1
18+
default: 2
19+
default: 3
20+
`)
21+
})

test/module.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,19 @@ import test from 'ava'
55
import {createConsole, getVersion} from '..'
66
import pkg from '../package'
77

8-
const expectedVersion = ((pkg.buildNumber === 0) && pkg.version) || `${pkg.version}${pkg.buildNumber}`
9-
108
const StreamProxy = new stream.PassThrough()
119
StreamProxy.setEncoding('utf8')
1210

1311
test(`Module version is '${pkg.version}'.`, t => {
14-
t.is(`${expectedVersion}`, getVersion())
12+
t.is(`${pkg.version}`, getVersion())
1513
})
1614

1715
test(`Module long version is '${pkg.name} v${pkg.version}'.`, t => {
18-
t.is(`${pkg.name} v${expectedVersion}`, getVersion(2))
16+
t.is(`${pkg.name} v${pkg.version}`, getVersion(2))
1917
})
2018

2119
const testConsole = createConsole({outStream: StreamProxy})
2220

23-
test('Verbosity Console‘s prototype inherits from console', t => {
24-
t.true(testConsole.prototype === Object.getPrototypeOf(console))
25-
})
26-
2721
test('Default level is 3 (log)', t => {
2822
t.is(testConsole.verbosity(), 3)
2923
})

0 commit comments

Comments
 (0)