Permalink
Browse files

feat: use consola for cli messages

  • Loading branch information...
pi0 committed Apr 2, 2018
1 parent 1cdd028 commit 1db2b2e6cd922244700c2e3f5d55f888e77ee7c7
Showing with 8 additions and 13 deletions.
  1. +7 −13 lib/module/index.js
  2. +1 −0 package.json
@@ -3,9 +3,12 @@ const { existsSync, readdirSync } = require('fs')
const merge = require('lodash/merge')
const uniq = require('lodash/uniq')
const defaults = require('./defaults')
const consola = require('consola')
const libRoot = resolve(__dirname, '..')
const logger = consola.withScope('nuxt:auth')
module.exports = function (moduleOptions) {
// Merge all option sources
const options = merge({}, defaults, moduleOptions, this.options.auth)
@@ -24,7 +27,7 @@ module.exports = function (moduleOptions) {
if (!options.defaultStrategy && strategies.length) {
options.defaultStrategy = strategies[0]._name
} else {
console.warn('no strategy defined!')
logger.warn('no strategy defined!')
}
// Copy plugin
@@ -34,10 +37,7 @@ module.exports = function (moduleOptions) {
function validateOptions (options) {
if (options.endpoints) {
// eslint-disable-next-line no-console
console.error(
'[DEPRECATED] [AUTH] ' +
'`auth.endpoints` has been moved into `auth.strategies.local`.'
)
logger.error('`auth.endpoints` has been moved into `auth.strategies.local`.')
options.strategies.local = merge({}, options.strategies.local, {
endpoints: options.endpoints
})
@@ -46,10 +46,7 @@ function validateOptions (options) {
if (options.watchLoggedIn) {
// eslint-disable-next-line no-console
console.error(
'[DEPRECATED] [AUTH] ' +
'`watchLoggedIn` has been deprecated. Use `redirect.logout` instead.'
)
logger.error('`watchLoggedIn` has been deprecated. Use `redirect.logout` instead.')
if (options.watchLoggedIn === false) {
options.redirect.logout = false
}
@@ -58,10 +55,7 @@ function validateOptions (options) {
// Enforce vuex store because auth depends on it
if (!this.options.store) {
throw new Error(
'[ERR] [AUTH] ' +
'Enable vuex store by creating `store/index.js`.'
)
logger.fatal('Enable vuex store by creating `store/index.js`.')
}
}
@@ -43,6 +43,7 @@
"dependencies": {
"@nuxtjs/axios": "^5.3.1",
"boom": "^7.2.0",
"consola": "^1.1.4",
"cookie": "^0.3.1",
"dotprop": "^1.0.2",
"js-cookie": "^2.2.0",

0 comments on commit 1db2b2e

Please sign in to comment.