New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

consola

Package Overview
Dependencies
Maintainers
3
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

consola - npm Package Compare versions

Comparing version 2.0.9 to 2.1.0

11

CHANGELOG.md

@@ -5,2 +5,13 @@ # Change Log

<a name="2.1.0"></a>
# [2.1.0](https://github.com/nuxt/consola/compare/v2.0.9...v2.1.0) (2018-11-03)
### Features
* add aliases ([cbea7bd](https://github.com/nuxt/consola/commit/cbea7bd))
* mockTypes for easy mocking ([a332890](https://github.com/nuxt/consola/commit/a332890))
<a name="2.0.9"></a>

@@ -7,0 +18,0 @@ ## [2.0.9](https://github.com/nuxt/consola/compare/v2.0.8...v2.0.9) (2018-11-03)

30

dist/consola.cjs.js

@@ -71,3 +71,4 @@ 'use strict';

this._stdout = options.stdout;
this._stderr = options.stdout; // Create logger functions for current instance
this._stderr = options.stdout;
this._mockFn = options.mockFn; // Create logger functions for current instance

@@ -78,2 +79,7 @@ for (const type in this._types) {

}, this._types[type], this._defaults));
} // Use _mockFn if is set
if (this._mockFn) {
this.mockTypes();
}

@@ -120,3 +126,4 @@ }

stdout: this._stdout,
stderr: this._stderr
stderr: this._stderr,
mockFn: this._mockFn
}, options));

@@ -235,7 +242,7 @@ }

pause() {
pauseLogs() {
paused = true;
}
resume() {
resumeLogs() {
paused = false; // Process queue

@@ -250,2 +257,14 @@

mockTypes(mockFn) {
this._mockFn = mockFn || this._mockFn;
if (typeof this._mockFn !== 'function') {
return;
}
for (const type in this._types) {
this[type] = this._mockFn(type, this._types[type]) || this[type];
}
}
_wrapLogFn(defaults) {

@@ -328,2 +347,5 @@ function logFn() {

Consola.prototype.withScope = Consola.prototype.withTag;
Consola.prototype.mock = Consola.prototype.mockTypes;
Consola.prototype.pause = Consola.prototype.pauseLogs;
Consola.prototype.resume = Consola.prototype.resumeLogs;

@@ -330,0 +352,0 @@ function assignGlobalReference(newInstance, referenceKey) {

@@ -63,3 +63,4 @@ (function (global, factory) {

this._stdout = options.stdout;
this._stderr = options.stdout; // Create logger functions for current instance
this._stderr = options.stdout;
this._mockFn = options.mockFn; // Create logger functions for current instance

@@ -70,2 +71,7 @@ for (const type in this._types) {

}, this._types[type], this._defaults));
} // Use _mockFn if is set
if (this._mockFn) {
this.mockTypes();
}

@@ -112,3 +118,4 @@ }

stdout: this._stdout,
stderr: this._stderr
stderr: this._stderr,
mockFn: this._mockFn
}, options));

@@ -227,7 +234,7 @@ }

pause() {
pauseLogs() {
paused = true;
}
resume() {
resumeLogs() {
paused = false; // Process queue

@@ -242,2 +249,14 @@

mockTypes(mockFn) {
this._mockFn = mockFn || this._mockFn;
if (typeof this._mockFn !== 'function') {
return;
}
for (const type in this._types) {
this[type] = this._mockFn(type, this._types[type]) || this[type];
}
}
_wrapLogFn(defaults) {

@@ -320,2 +339,5 @@ function logFn() {

Consola.prototype.withScope = Consola.prototype.withTag;
Consola.prototype.mock = Consola.prototype.mockTypes;
Consola.prototype.pause = Consola.prototype.pauseLogs;
Consola.prototype.resume = Consola.prototype.resumeLogs;

@@ -322,0 +344,0 @@ const TYPE_COLOR_MAP = {

2

package.json
{
"name": "consola",
"version": "2.0.9",
"version": "2.1.0",
"description": "Elegant Console Logger for Node.js and Browser",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -22,2 +22,3 @@ <p align="center">

- Pause/Resume support
- Mocking support

@@ -58,2 +59,4 @@ ## Installation

- Aliases: `add`
Register a custom reporter instance.

@@ -63,2 +66,4 @@

- Aliases: `remove`, `clear`
Remove a registered reporter.

@@ -70,4 +75,2 @@

- Type: `Object` or `Array`
Replace all reporters.

@@ -85,2 +88,4 @@

- Aliases: `withScope`
Create a new `Consola` instance with that tag.

@@ -103,4 +108,6 @@

#### `pause()` `resume()`
#### `pauseLogs()` `resumeLogs()`
- Aliases: `pause`/`resume`
**Globally** pause and resume logs.

@@ -110,2 +117,32 @@

#### `mockTypes`
- Aliases: `mock`
Mock all types. Useful for using with tests.
The first argument passed to `mockTypes` should be a callback function accepting `(typeName, type)` and returning the mocked value:
```js
consola.mockTypes((typeName, type) => jest.fn())
```
Please note that with the example above, everything is mocked independently for each type. If you need one mocked fn create it outside:
```js
const fn = jest.fn()
consola.mockTypes(() => fn)
```
If callback function returns a _falsy_ value, that type won't be mocked.
For example if you just need to mock `consola.fatal`:
```js
consola.mockTypes((typeName) => typeName === 'fatal' && jest.fn())
```
**NOTE:** Any instance of consola that inherits the mocked instance, will apply provided callback again.
This way, mocking works for `withTag` scopped logers without need to extra efforts.
## Fields

@@ -136,2 +173,6 @@

Extra fields:
- `badge`
## Reporters

@@ -183,5 +224,3 @@

```js
consola.setReporters({
log: jest.fn()
})
consola.mockTypes(() => jest.fn())
```

@@ -188,0 +227,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc