Skip to content

Commit 1db2b2e

Browse files
author
Pooya Parsa
committed
feat: use consola for cli messages
1 parent 1cdd028 commit 1db2b2e

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

lib/module/index.js

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ const { existsSync, readdirSync } = require('fs')
33
const merge = require('lodash/merge')
44
const uniq = require('lodash/uniq')
55
const defaults = require('./defaults')
6+
const consola = require('consola')
67

78
const libRoot = resolve(__dirname, '..')
89

10+
const logger = consola.withScope('nuxt:auth')
11+
912
module.exports = function (moduleOptions) {
1013
// Merge all option sources
1114
const options = merge({}, defaults, moduleOptions, this.options.auth)
@@ -24,7 +27,7 @@ module.exports = function (moduleOptions) {
2427
if (!options.defaultStrategy && strategies.length) {
2528
options.defaultStrategy = strategies[0]._name
2629
} else {
27-
console.warn('no strategy defined!')
30+
logger.warn('no strategy defined!')
2831
}
2932

3033
// Copy plugin
@@ -34,10 +37,7 @@ module.exports = function (moduleOptions) {
3437
function validateOptions (options) {
3538
if (options.endpoints) {
3639
// eslint-disable-next-line no-console
37-
console.error(
38-
'[DEPRECATED] [AUTH] ' +
39-
'`auth.endpoints` has been moved into `auth.strategies.local`.'
40-
)
40+
logger.error('`auth.endpoints` has been moved into `auth.strategies.local`.')
4141
options.strategies.local = merge({}, options.strategies.local, {
4242
endpoints: options.endpoints
4343
})
@@ -46,10 +46,7 @@ function validateOptions (options) {
4646

4747
if (options.watchLoggedIn) {
4848
// eslint-disable-next-line no-console
49-
console.error(
50-
'[DEPRECATED] [AUTH] ' +
51-
'`watchLoggedIn` has been deprecated. Use `redirect.logout` instead.'
52-
)
49+
logger.error('`watchLoggedIn` has been deprecated. Use `redirect.logout` instead.')
5350
if (options.watchLoggedIn === false) {
5451
options.redirect.logout = false
5552
}
@@ -58,10 +55,7 @@ function validateOptions (options) {
5855

5956
// Enforce vuex store because auth depends on it
6057
if (!this.options.store) {
61-
throw new Error(
62-
'[ERR] [AUTH] ' +
63-
'Enable vuex store by creating `store/index.js`.'
64-
)
58+
logger.fatal('Enable vuex store by creating `store/index.js`.')
6559
}
6660
}
6761

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"dependencies": {
4444
"@nuxtjs/axios": "^5.3.1",
4545
"boom": "^7.2.0",
46+
"consola": "^1.1.4",
4647
"cookie": "^0.3.1",
4748
"dotprop": "^1.0.2",
4849
"js-cookie": "^2.2.0",

0 commit comments

Comments
 (0)