How to use the npm/lib/cache.add 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 _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,
        pkg = pkg.join("@");

    // at this point, assume that it has to be debianized
    if (exact) {
        log.verbose("exact", pkg);
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)
    , exact = semver.valid(ver)
    , tag = !exact && !range && range !== "" && ver
  log.verbose([pkg, mustHave], "must install?")
  pkg = pkg.join("@")
  seen[name+"@"+ver] = true

  // if there is a satisfying version already, then simply move on.