How to use the consola.withScope function in consola

To help you get started, we’ve selected a few consola examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Developmint / nuxt-svg-loader / lib / module.js View on Github external
const logger = require('consola').withScope('nuxt-svg-loader')

export default function nuxtSvgLoader() {
  const { svgLoader: options } = this.options

  if (options && options.svgo && !options.svgoConfig) {
    options.svgoConfig = options.svgo
  }

  this.extendBuild(setupVueSvgLoader(options))
}

const svgRulePredicate = rule => rule.test && rule.test.test('.svg')

const setupVueSvgLoader = options => (config) => {
  // https://github.com/egoist/svg-to-vue-component#nuxtjs-2
  const imageLoaderRule = config.module.rules.find(svgRulePredicate)
github nuxt-community / style-resources-module / lib / module.js View on Github external
const glob = require('glob-all')
const consola = require('consola')
const logger = consola.withScope('nuxt-style-resources')

export default function nuxtStyledResources(moduleOptions) {
  const resolver = (this.nuxt.resolver || this.nuxt)

  const {
    styleResources = moduleOptions,
    build: {
      styleResources: legacyStyledResources,
      loaders: { stylus: stylusLoaderOptions }
    }
  } = this.options

  // A bit messy. Check for truthyness and keys and return
  const legacyResources = legacyStyledResources && Object.keys(legacyStyledResources).length && legacyStyledResources

  const resources = legacyResources || styleResources
github bazzite / nuxt-netlify / lib / index.js View on Github external
/**
 * Copyright (c) 2019, Bazzite, LLC
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

const path = require('path')
const consola = require('consola')

const { DEFAULT_CONFIG } = require('./constants')
const generateHeaders = require('./headers')
const generateRedirects = require('./redirects')
const { createFile } = require('./utils')

const logger = consola.withScope('nuxt:@bazzite/nuxt-netlify')

function nuxtOptimizedImages (moduleOptions) {
  const { rootDir, generate, build } = this.options
  const options = Object.assign({}, DEFAULT_CONFIG, this.options.netlify, moduleOptions)
  options.publicPath = build.publicPath

  // validate options
  if (typeof options.headers !== 'object') {
    logger.fatal('The `headers` property must be an object')
  } else if (!Array.isArray(options.redirects)) {
    logger.fatal('The `redirects` property must be an array')
  } else if (typeof options.transformHeaders !== 'function') {
    logger.fatal('The `transformHeaders` property must be a function')
  }

  // Generate headers and redirects in dist
github nuxt / http / lib / module.js View on Github external
const path = require('path')
const consola = require('consola')
const semver = require('semver')

const logger = consola.withScope('nuxt:http')

function httpModule (_moduleOptions) {
  // Combine options
  const moduleOptions = { ...this.options.http, ..._moduleOptions }

  // Default port
  const defaultPort =
    process.env.API_PORT ||
    moduleOptions.port ||
    process.env.PORT ||
    process.env.npm_package_config_nuxt_port ||
    3000

  // Default host
  let defaultHost =
    process.env.API_HOST ||
github Cretezy / Noderize / packages / scripts / src / utils / logger.js View on Github external
import consola from "consola";

export const appLogger = consola.withScope("app");
export const buildLogger = consola.withScope("build");
export const configLogger = consola.withScope("config");
export const copyLogger = consola.withScope("copy");
export const cleanLogger = consola.withScope("clean");
export const formatLogger = consola.withScope("format");
export const lintLogger = consola.withScope("lint");
export const startLogger = consola.withScope("start");
export const testLogger = consola.withScope("test");
export const watchLogger = consola.withScope("watch");

export function printLines(printMethod, lines, prefix = "") {
  lines.split("\n").forEach(line => printMethod(`${prefix}${line}`));
}
github Cretezy / Noderize / packages / scripts / src / utils / logger.js View on Github external
import consola from "consola";

export const appLogger = consola.withScope("app");
export const buildLogger = consola.withScope("build");
export const configLogger = consola.withScope("config");
export const copyLogger = consola.withScope("copy");
export const cleanLogger = consola.withScope("clean");
export const formatLogger = consola.withScope("format");
export const lintLogger = consola.withScope("lint");
export const startLogger = consola.withScope("start");
export const testLogger = consola.withScope("test");
export const watchLogger = consola.withScope("watch");

export function printLines(printMethod, lines, prefix = "") {
  lines.split("\n").forEach(line => printMethod(`${prefix}${line}`));
}
github bugsnag / bugsnag-js / examples / nuxtjs / modules / bugsnag / index.js View on Github external
export default function (options) {
  const logger = consola.withScope('Bugsnag')
  logger.info('Configuring')

  const bugsnagOptions = { ...this.options.bugsnag, ...options.bugsnag }

  logger.info('Adding browser plugin')
  this.addPlugin({
    src: join(__dirname, 'client.js'),
    options: { apiKey: bugsnagOptions.browserApiKey },
    ssr: false
  })

  Bugsnag.init({ apiKey: bugsnagOptions.serverApiKey, logger })
  Bugsnag.use(bugsnagExpress)

  logger.info('Adding server handlers')
  this.nuxt.hook('render:setupMiddleware', app => app.use(Bugsnag.getPlugin('express').requestHandler))
github nuxt / typescript / packages / typescript-build / src / index.ts View on Github external
transpileOnly: true,
              [`append${ext.charAt(0).toUpperCase() + ext.slice(1)}SuffixTo`]: [/\.vue$/],
              ...(options.loaders && options.loaders[ext])
            }
          }
        ]
      })
    ))

    if (options.typeCheck && isClient && !isModern) {
      const ForkTsCheckerWebpackPlugin = require(this.nuxt.resolver.resolveModule('fork-ts-checker-webpack-plugin'))
      config.plugins!.push(new ForkTsCheckerWebpackPlugin(Object.assign({
        vue: true,
        tsconfig: path.resolve(this.options.rootDir!, 'tsconfig.json'),
        formatter: 'codeframe',
        logger: consola.withScope('nuxt:typescript')
      }, options.typeCheck)))
    }
  })
}
github nuxt / typescript / packages / typescript-build / src / index.ts View on Github external
transpileOnly: true,
              [`append${ext.charAt(0).toUpperCase() + ext.slice(1)}SuffixTo`]: [/\.vue$/],
              ...(options.loaders && options.loaders[ext])
            }
          }
        ]
      })
    ))

    if (options.typeCheck && isClient && !isModern) {
      const ForkTsCheckerWebpackPlugin = require(this.nuxt.resolver.resolveModule('fork-ts-checker-webpack-plugin'))
      config.plugins!.push(new ForkTsCheckerWebpackPlugin(Object.assign({
        vue: true,
        tsconfig: path.resolve(this.options.rootDir!, 'tsconfig.json'),
        formatter: 'codeframe',
        logger: consola.withScope('nuxt:typescript')
      }, options.typeCheck)))
    }
  })
}
github nuxt-community / nuxtent-module / lib / util / debug.js View on Github external
import consola from 'consola'

/**
 * @type {Function} The consola logger
 */
const logger = consola.withScope('nuxt:nuxtent')
export default logger