How to use the npm/lib/utils/log.verbose function in npm

To help you get started, we’ve selected a few npm 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 arikon / npm2debian / lib / source.js View on Github external
function install_ (pkg, reg, seen, mustHave, pkglist, cb) {
  log.verbose(pkg, "install_")
  if (seen[pkg]) return cb() // repeat, skip it
  seen[pkg] = true

  // it's a local thing or a url if it has a / in it.
  if (pkg.indexOf("/") !== -1 || pkg === ".") {
    log.silly(pkg, "install local")
    return cache.add(pkg, finisher(pkg, reg, pkglist, cb))
  }

  // now we know it's not a URL or file,
  // so handle it like a tag, version, or range.
  pkg = pkg.split("@")
  var name = pkg[0]
    , defTag = npm.config.get("tag")
    , ver = pkg.slice(1).join("@").trim() || defTag
    , range = semver.validRange(ver)
github arikon / npm2debian / lib / source.js View on Github external
function _source(pkg, reg, pkglist, cb) {
    log.verbose(pkg, "_source");

    // it's a local thing or a url if it has a / in it.
    if (pkg.indexOf("/") !== -1 || pkg === ".") {
        log.silly(pkg, "install local");
        return cache.add(pkg, finisher(pkg, reg, pkglist, cb));
    }

    // now we know it's not a URL or file,
    // so handle it like a tag, version, or range.
    pkg = pkg.split("@");
    var name = pkg[0],
        defTag = npm.config.get("tag"),
        ver = pkg.slice(1).join("@").trim() || defTag,
        range = semver.validRange(ver),
        exact = semver.valid(ver),
        tag = !exact && !range && range !== "" && ver,
github arikon / npm2debian / lib / source.js View on Github external
function install (pkglist, cb) {
  if (pkglist.length === 0) pkglist = ["."]
  // it's helpful to know what we have already
  if (!installedPackages) return readInstalled([], function (er, data) {
    if (er) return cb(er)
    installedPackages = data || {}
    install(pkglist, cb)
  })

  log.verbose(pkglist, "install pkglist")
  var mustInstall = pkglist.slice(0)

  // three lists: "pkglist", "next", and "reg"
  // asyncMap over the "left" list: for each "it"
  //   find out what it is
  //   if it's version/range installed or on "reg" list, continue.
  //   if it's a url, fetch to cache and add the name/version to "next"
  //   if it's a tag, fetch the json, add the version to "next"
  //   if it's a version(range) not installed, then fetch the json,
  //     add url to "next"
  //   if it's a specific version in cache, then unpack, add to "reg"
  //     list, add its deps to "next"
  // if the "next" list is not empty, then pkglist=next,next=[], and repeat.
  // if it is, then build all the "reg" folders.

  var reg = Object.create(installedPackages)
github arikon / npm2debian / lib / source.js View on Github external
getData(name, function (er, data) {
    if (er) return cb(er)
    log.silly(data, pkg)
    if (tag) {
      log.verbose(tag, pkg+" tag")
      var tags = data["dist-tags"]
      if (!tags[tag]) return log.er(cb, "Tag not found: "+data.name+"@"+tag)(er)
      install_(data.name+"@"+tags[tag], reg, seen, mustHave, pkglist, cb)
    } else {
      log.verbose(tag, pkg+" range")
      // prefer the default tag version.
      var defTag = npm.config.get("tag")
        , satis
      defTag = defTag && data["dist-tags"] && data["dist-tags"][defTag]
      if (semver.satisfies(defTag, range)) satis = defTag
      else satis = semver.maxSatisfying(Object.keys(data.versions), range)

      if (!satis) return cb(new Error(
        "No satisfying version found for '"+data.name+"'@'"+range+"'"))
      install_(data.name+"@"+satis, reg, seen, mustHave, pkglist, cb)
    }
  })
}
github arikon / npm2debian / lib / source.js View on Github external
function rollbackFailure (installList, cb) { return function (er) {
  if (!er) return log.verbose(installList.map(function (i) {
    return i.join("@")
  }).join("\n"), "installed", cb)
  // error happened, roll back
  installList = installList.map(function (p) {
    return (""+p).replace(/\//, '@')
  })
  npm.ROLLBACK = true
  log.error(er, "install failed")
  log("rollback", "install failed")
  return npm.commands.uninstall
    ( installList
    , function (er_) {
        if (er_) log.error(er_, "rollback failed")
        else log("rolled back", "install failed")
        cb(er)
      }
github arikon / npm2debian / cli.js View on Github external
npm = require('npm'),
    ini = require('npm/lib/utils/ini'),
    rm = require('npm/lib/utils/rm-rf'),
    npm2debian = require('./npm2debian'),

    // supported commands.
    argv = process.argv.slice(2),
    arg = '',

    conf = {},
    key,
    arglist = [],
    command,
    flagsDone;

log.verbose(argv, 'cli');

while (arg = argv.shift()) {
    if (!key && (arg.match(/^-+[h?]$/i))) arg = '--usage';
    if (!command && (npm2debian.commands.hasOwnProperty(arg))) {
        if (key) {
            conf[key] = true;
            key = null;
        }
        command = arg;
    } else if (!flagsDone && arg.substr(0, 2) === '--') {
        if (key) conf[key] = true;
        key = arg.substr(2);
        if (key === 'usage') conf[key] = true, key = null;
        flagsDone = (key === '');
    } else if (key) {
        conf[key] = arg;