Comparing version 1.0.1 to 2.0.0
@@ -5,2 +5,16 @@ # Change Log | ||
# [2.0.0](https://github.com/jsless/hable/compare/v1.0.1...v2.0.0) (2019-08-21) | ||
### Features | ||
* custom logger ([ada6e37](https://github.com/jsless/hable/commit/ada6e37)) | ||
### BREAKING CHANGES | ||
* console is replaced by consola by default | ||
## [1.0.1](https://github.com/jsless/hable/compare/v1.0.0...v1.0.1) (2019-03-16) | ||
@@ -7,0 +21,0 @@ |
@@ -1,7 +0,6 @@ | ||
const { serial } = require('items-promise') | ||
const consola = require('consola') | ||
const { flatHooks } = require('./utils') | ||
const { serial, flatHooks } = require('./utils') | ||
module.exports = class Hookable { | ||
constructor () { | ||
constructor (logger = console) { | ||
this.logger = logger | ||
this._hooks = {} | ||
@@ -20,3 +19,3 @@ this._deprecatedHooks = {} | ||
if (this._deprecatedHooks[name]) { | ||
consola.warn(`${name} hook has been deprecated, please use ${this._deprecatedHooks[name]}`) | ||
this.logger.warn(`${name} hook has been deprecated, please use ${this._deprecatedHooks[name]}`) | ||
name = this._deprecatedHooks[name] | ||
@@ -48,3 +47,3 @@ } | ||
name !== 'error' && await this.callHook('error', err) | ||
consola.error(err) | ||
this.logger.error(err) | ||
} | ||
@@ -51,0 +50,0 @@ } |
@@ -13,1 +13,5 @@ exports.flatHooks = function flatHooks (configHooks, hooks = {}, parentName) { | ||
} | ||
exports.serial = function serial (tasks, fn) { | ||
return tasks.reduce((promise, task) => promise.then(previous => fn(task, previous)), Promise.resolve(null)) | ||
} |
{ | ||
"name": "hable", | ||
"version": "1.0.1", | ||
"version": "2.0.0", | ||
"description": "Awaitable hooks for Node.js", | ||
@@ -29,6 +29,2 @@ "license": "MIT", | ||
}, | ||
"dependencies": { | ||
"consola": "^2.4.0", | ||
"items-promise": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
@@ -35,0 +31,0 @@ "codecov": "^3.0.0", |
@@ -36,2 +36,4 @@ # Hable | ||
super() | ||
// Initialize Hookable with custom logger | ||
// super(consola) | ||
} | ||
@@ -66,3 +68,12 @@ | ||
### `constructor(logger)` | ||
Custom logger. Default logger is `console` but you can use your own or [consola](https://github.com/nuxt/consola). | ||
It should be an object implementing following functions: | ||
- log | ||
- warn | ||
- error | ||
- debug | ||
### `hook (name, fn)` | ||
@@ -69,0 +80,0 @@ |
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
8688
0
64
126
- Removedconsola@^2.4.0
- Removeditems-promise@^1.0.0
- Removedconsola@2.15.3(transitive)
- Removeditems-promise@1.0.0(transitive)