feat(core): better log message formatting
This commit is contained in:
parent
8badef08f8
commit
88f74a4e5e
2 changed files with 5 additions and 5 deletions
|
@ -46,7 +46,7 @@ export function Store(methods = []) {
|
||||||
|
|
||||||
for (const [path, method] of methods) {
|
for (const [path, method] of methods) {
|
||||||
if (avoid.indexOf(path) !== -1) {
|
if (avoid.indexOf(path) !== -1) {
|
||||||
this.log.warning(`You cannot overwrite store.${path}()`)
|
this.log.warning(`You cannot overwrite \`store.${path}()\``)
|
||||||
} else set(this, path, method)
|
} else set(this, path, method)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,9 +66,9 @@ export function Store(methods = []) {
|
||||||
Store.prototype.extend = function (methods) {
|
Store.prototype.extend = function (methods) {
|
||||||
for (const [path, method] of methods) {
|
for (const [path, method] of methods) {
|
||||||
if (avoid.indexOf(path) !== -1) {
|
if (avoid.indexOf(path) !== -1) {
|
||||||
this.log.warning(`You cannot overwrite store.${path}()`)
|
this.log.warning(`You cannot overwrite \`store.${path}()\``)
|
||||||
} else {
|
} else {
|
||||||
this.log.info(`Extending store with ${path}`)
|
this.log.info(`Extending store with \`${path}\``)
|
||||||
set(this, path, (...args) => method(this, ...args))
|
set(this, path, (...args) => method(this, ...args))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,14 +77,14 @@ describe('Store', () => {
|
||||||
it('Should log a warning when trying to extend a protected method via the constructor', () => {
|
it('Should log a warning when trying to extend a protected method via the constructor', () => {
|
||||||
const store = new Store([['get', () => false]])
|
const store = new Store([['get', () => false]])
|
||||||
expect(store.logs.warning.length).to.equal(1)
|
expect(store.logs.warning.length).to.equal(1)
|
||||||
expect(store.logs.warning[0]).to.equal('You cannot overwrite store.get()')
|
expect(store.logs.warning[0]).to.equal('You cannot overwrite `store.get()`')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should log a warning when trying to extend a protected method via the extend', () => {
|
it('Should log a warning when trying to extend a protected method via the extend', () => {
|
||||||
const store = new Store()
|
const store = new Store()
|
||||||
store.extend([['get', () => false]])
|
store.extend([['get', () => false]])
|
||||||
expect(store.logs.warning.length).to.equal(1)
|
expect(store.logs.warning.length).to.equal(1)
|
||||||
expect(store.logs.warning[0]).to.equal('You cannot overwrite store.get()')
|
expect(store.logs.warning[0]).to.equal('You cannot overwrite `store.get()`')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should extend the store with a new method via the constructor', () => {
|
it('Should extend the store with a new method via the constructor', () => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue