How to use the npmlog.level function in npmlog

To help you get started, we’ve selected a few npmlog 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 lerna / lerna / test / RunCommand.js View on Github external
// helpers
import callsBack from "./helpers/callsBack";
import initFixture from "./helpers/initFixture";
import normalizeRelativeDir from "./helpers/normalizeRelativeDir";
import yargsRunner from "./helpers/yargsRunner";

// file under test
import * as commandModule from "../src/commands/RunCommand";

const run = yargsRunner(commandModule);

jest.mock("../src/NpmUtilities");
jest.mock("../src/utils/output");

// silence logs
log.level = "silent";

const ranInPackages = testDir =>
  NpmUtilities.runScriptInDir.mock.calls.reduce((arr, [script, cfg]) => {
    const { args, directory } = cfg;
    const dir = normalizeRelativeDir(testDir, directory);
    arr.push([dir, script].concat(args).join(" "));
    return arr;
  }, []);

const ranInPackagesStreaming = testDir =>
  NpmUtilities.runScriptInPackageStreaming.mock.calls.reduce((arr, [script, cfg]) => {
    const { args, pkg } = cfg;
    const dir = normalizeRelativeDir(testDir, pkg.location);
    arr.push([dir, script].concat(args).join(" "));
    return arr;
  }, []);
github graalvm / graaljs / deps / npm / lib / utils / error-handler.js View on Github external
if (!cbCalled) {
      log.error('', 'cb() never called!')
      console.error('')
      log.error('', 'This is an error with npm itself. Please report this error at:')
      log.error('', '    ')
      writeLogFile()
    }

    if (code) {
      log.verbose('code', code)
    }
  }
  if (npm.config.loaded && npm.config.get('timing') && !wroteLogFile) writeLogFile()
  if (wroteLogFile) {
    // just a line break
    if (log.levels[log.level] <= log.levels.error) console.error('')

    log.error(
      '',
      [
        'A complete log of this run can be found in:',
        '    ' + getLogFile()
      ].join('\n')
    )
    wroteLogFile = false
  }

  var doExit = npm.config.loaded && npm.config.get('_exit')
  if (doExit) {
    // actually exit.
    if (exitCode === 0 && !itWorked) {
      exitCode = 1
github ShieldBattery / ShieldBattery / deps / node / deps / npm / lib / utils / error-handler.js View on Github external
function exit (code, noLog) {
  exitCode = exitCode || process.exitCode || code

  var doExit = npm.config.get("_exit")
  log.verbose("exit", [code, doExit])
  if (log.level === "silent") noLog = true

  if (code && !noLog) writeLogFile(reallyExit)
  else rm("npm-debug.log", function () { rm(npm.tmp, reallyExit) })

  function reallyExit() {
    // truncate once it's been written.
    log.record.length = 0

    itWorked = !code

    // just emit a fake exit event.
    // if we're really exiting, then let it exit on its own, so that
    // in-process stuff can finish or clean up first.
    if (!doExit) process.emit("exit", code)
    npm.spinner.stop()
  }
github nullivex / nodist / bin / node_modules / npm / node_modules / node-gyp / lib / node-gyp.js View on Github external
Object.keys(process.env).forEach(function (name) {
    if (name.indexOf(npm_config_prefix) !== 0) return
    var val = process.env[name]
    if (name === npm_config_prefix + 'loglevel') {
      log.level = val
    } else {
      // add the user-defined options to the config
      name = name.substring(npm_config_prefix.length)
      this.opts[name] = val
    }
  }, this)
github npm / pacote / test / registry.packument.js View on Github external
name: 'foo',
      version: '1.2.1'
    },
    '1.2.3': BASE,
    '1.2.4': {
      name: 'foo',
      version: '1.2.4'
    },
    '3.4.5': {
      name: 'foo',
      version: '3.4.5'
    }
  }
}

npmlog.level = process.env.LOGLEVEL || 'silent'
const OPTS = {
  registry: 'https://mock.reg',
  log: npmlog,
  retry: {
    retries: 1,
    factor: 1,
    minTimeout: 1,
    maxTimeout: 10
  }
}

test('fetches packument from registry', t => {
  const srv = tnock(t, OPTS.registry)

  srv.get('/foo').reply(200, META)
  return packument('foo', OPTS).then(meta => {
github npm / pacote / test / remote.tarball.js View on Github external
'use strict'

const getBuff = require('get-stream').buffer
const mockTar = require('./util/mock-tarball')
const npa = require('npm-package-arg')
const npmlog = require('npmlog')
const test = require('tap').test
const tnock = require('./util/tnock')

require('./util/test-dir')(__filename)

const fetch = require('../lib/fetch')

npmlog.level = process.env.LOGLEVEL || 'silent'
const OPTS = {
  log: npmlog,
  registry: 'https://my.mock.registry/',
  retry: {
    retries: 1,
    factor: 1,
    minTimeout: 1,
    maxTimeout: 10
  }
}

test('basic tarball streaming', function (t) {
  const pkg = {
    'package.json': JSON.stringify({
      name: 'foo',
      version: '1.2.3'
github davidhealey / waistline / node_modules / npm / lib / utils / lifecycle.js View on Github external
function runCmd (note, cmd, pkg, env, stage, wd, unsafe, cb) {
  if (running) {
    queue.push([note, cmd, pkg, env, stage, wd, unsafe, cb])
    return
  }

  running = true
  log.pause()
  var user = unsafe ? null : npm.config.get("user")
    , group = unsafe ? null : npm.config.get("group")

  if (log.level !== 'silent') {
    if (npm.spinner.int) {
      npm.config.get("logstream").write("\r \r")
    }
    console.log(note)
  }
  log.verbose("unsafe-perm in lifecycle", unsafe)

  if (process.platform === "win32") {
    unsafe = true
  }

  if (unsafe) {
    runCmd_(cmd, pkg, env, wd, stage, unsafe, 0, 0, cb)
  } else {
    uidNumber(user, group, function (er, uid, gid) {
      runCmd_(cmd, pkg, env, wd, stage, unsafe, uid, gid, cb)
github angelozerr / tern.java / eclipse / tern.eclipse.ide.server.nodejs.embed.linux.gtk.x86 / nodejs / node-v0.10.22-linux-x86 / lib / node_modules / npm / lib / help.js View on Github external
function npmUsage (cb) {
  npm.config.set("loglevel", "silent")
  log.level = "silent"
  console.log
    ( ["\nUsage: npm "
      , ""
      , "where  is one of:"
      , npm.config.get("long") ? usages()
        : "    " + wrap(Object.keys(npm.commands))
      , ""
      , "npm  -h     quick help on "
      , "npm -l           display full usage info"
      , "npm faq          commonly asked questions"
      , "npm help   search for help on "
      , "npm help npm     involved overview"
      , ""
      , "Specify configs in the ini-formatted file:"
      , "    " + npm.config.get("userconfig")
      , "or on the command line via: npm  --key value"
github Mailtrain-org / mailtrain / setup / sql / init.js View on Github external
'use strict';

let dbcheck = require('../../lib/dbcheck');
let log = require('npmlog');
let path = require('path');
let fs = require('fs');

log.level = 'verbose';

if (process.env.NODE_ENV === 'production') {
    log.error('sqlinit', 'This script does not run in production');
    process.exit(1);
}

if (process.env.NODE_ENV === 'test' && !fs.existsSync(path.join(__dirname, '..', '..', 'config', 'test.toml'))) {
    log.error('sqlinit', 'This script only runs in test if config/test.toml (i.e. a dedicated test database) is present');
    process.exit(1);
}

dbcheck(err => {
    if (err) {
        log.error('DB', err);
        return process.exit(1);
    }
github hisabimbola / slack-history-export / src / cli.js View on Github external
coerce: (level) => {
      log.level = level
      return level
    },
  })