How to use the npm/lib/utils/log.error 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 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
function errorHandler(er) {
    if (cbCalled) throw new Error('Callback called more than once.');
    cbCalled = true;
    if (!er) {
        itWorked = true;
        log.win('ok');
        return exit();
    }
    log.error(er);
    if (!(er instanceof Error)) return exit(1);
    if (npm2debian.commands[command].usage) {
        log.error(npm2debian.commands[command].usage);
    }
    log.error([
        'try running: "npm2debian help ' + command + '"',
        'Report this *entire* log at '
    ].join('\n'));
    exit(1);
}
github arikon / npm2debian / cli.js View on Github external
function errorHandler(er) {
    if (cbCalled) throw new Error('Callback called more than once.');
    cbCalled = true;
    if (!er) {
        itWorked = true;
        log.win('ok');
        return exit();
    }
    log.error(er);
    if (!(er instanceof Error)) return exit(1);
    if (npm2debian.commands[command].usage) {
        log.error(npm2debian.commands[command].usage);
    }
    log.error([
        'try running: "npm2debian help ' + command + '"',
        'Report this *entire* log at '
    ].join('\n'));
    exit(1);
}
github arikon / npm2debian / cli.js View on Github external
function errorHandler(er) {
    if (cbCalled) throw new Error('Callback called more than once.');
    cbCalled = true;
    if (!er) {
        itWorked = true;
        log.win('ok');
        return exit();
    }
    log.error(er);
    if (!(er instanceof Error)) return exit(1);
    if (npm2debian.commands[command].usage) {
        log.error(npm2debian.commands[command].usage);
    }
    log.error([
        'try running: "npm2debian help ' + command + '"',
        'Report this *entire* log at '
    ].join('\n'));
    exit(1);
}
github arikon / npm2debian / npm2debian.js View on Github external
process.title = "npm2debian";

var npm2debian = exports,
    //set = require("npm/utils/set"),
    //get = require("npm/utils/get"),
    //ini = require("npm/utils/ini"),
    log = require("npm/lib/utils/log"),
    fs = require("npm/lib/utils/graceful-fs"),
    path = require("path");

npm2debian.commands = {};


if (process.getuid() === 0) {
    log.error("\nRunning npm2debian as root is not recommended!\n"
        + "Seriously, don't do this!\n", "sudon't!");
}

try {
    var j = JSON.parse(fs.readFileSync(path.join(__dirname, "package.json")) + "");
    npm2debian.version = j.version;
    npm2debian.nodeVersionRequired = j.engines.node;
} catch (ex) {
    log(ex, "error reading version");
    npm2debian.version = ex;
}

var commandCache = {};
[ "source", /*"binary", */"help"].forEach(function (c) {
    Object.defineProperty(npm2debian.commands, c, {
        get : function () {
github arikon / npm2debian / lib / source.js View on Github external
, function (er_) {
        if (er_) log.error(er_, "rollback failed")
        else log("rolled back", "install failed")
        cb(er)
      }
    )