How to use the npm.version 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 apmjs / apmjs / bin / cli.js View on Github external
npm.argv = conf.argv.remain
  if (npm.deref(npm.argv[0])) npm.command = npm.argv.shift()
  else conf.usage = true

  if (conf.version) {
    console.log(pkg.version)
    return errorHandler.exit(0)
  }

  if (conf.versions) {
    npm.command = 'version'
    conf.usage = false
    npm.argv = []
  }

  log.info('using', 'npm@%s', npm.version)
  log.info('using', 'node@%s', process.version)

  process.on('uncaughtException', errorHandler)

  if (conf.usage && npm.command !== 'help') {
    npm.argv.unshift(npm.command)
    npm.command = 'help'
  }

  // now actually fire up npm and run the command.
  // this is how to use npm programmatically:
  conf._exit = true
  npm.load(conf, function (er) {
    // this log is different from the one required by npm
    log.level = npm.config.get('loglevel')
    log.resume()
github pimatic / pimatic / ppm.js View on Github external
#!/usr/bin/env node
/*
  Modified version of https://github.com/npm/npm/blob/master/bin/npm-cli.js
  Copyright (c) npm, Inc. and Contributors
  Licensed on the terms of The Artistic License 2.0
  See https://github.com/npm/npm/blob/master/LICENSE
*/
var path = require("path");
var npm = require("npm");
var semver = require('semver');

if(!semver.satisfies(npm.version, '2.*')) {
  console.log("Error: npm version " + npm.version + " is not supported by ppm. "
    + "Please install npm v2 globally ('npm install -g npm@2') or locally in your "
    + "pimatic-app directory ('npm install npm@2'). See you again.");
  process.exit(1);
}

process.title = "ppm";

var log = require("npm/node_modules/npmlog");
log.pause() // will be unpaused when config is loaded.
log.info("it worked if it ends with", "ok");


var npmconf = require("npm/lib/config/core.js");
var errorHandler = require("npm/lib/utils/error-handler.js");
github pimatic / pimatic / ppm.js View on Github external
#!/usr/bin/env node
/*
  Modified version of https://github.com/npm/npm/blob/master/bin/npm-cli.js
  Copyright (c) npm, Inc. and Contributors
  Licensed on the terms of The Artistic License 2.0
  See https://github.com/npm/npm/blob/master/LICENSE
*/
var path = require("path");
var npm = require("npm");
var semver = require('semver');

if(!semver.satisfies(npm.version, '2.*')) {
  console.log("Error: npm version " + npm.version + " is not supported by ppm. "
    + "Please install npm v2 globally ('npm install -g npm@2') or locally in your "
    + "pimatic-app directory ('npm install npm@2'). See you again.");
  process.exit(1);
}

process.title = "ppm";

var log = require("npm/node_modules/npmlog");
log.pause() // will be unpaused when config is loaded.
log.info("it worked if it ends with", "ok");


var npmconf = require("npm/lib/config/core.js");
var errorHandler = require("npm/lib/utils/error-handler.js");

var configDefs = npmconf.defs;
github pimatic / pimatic / ppm.js View on Github external
if (npm.deref(npm.argv[0])) npm.command = npm.argv.shift()
else conf.usage = true


if (conf.version) {
  console.log(npm.version)
  return
}

if (conf.versions) {
  npm.command = "version"
  conf.usage = false
  npm.argv = []
}

log.info("using", "npm@%s", npm.version)
log.info("using", "node@%s", process.version)

process.on("uncaughtException", function(err){console.log(err.stack);})

if (conf.usage && npm.command !== "help") {
  npm.argv.unshift(npm.command)
  npm.command = "help"
}

// now actually fire up npm and run the command.
// this is how to use npm programmatically:
conf._exit = true
npm.load(conf, function (er) {
  if (er) return errorHandler(er)

  // we are patching install with out modified routine
github pimatic / pimatic / ppm.js View on Github external
// if npm is called as "npmg" or "npm_g", then
// run in global mode.
if (path.basename(process.argv[1]).slice(-1)  === "g") {
  process.argv.splice(1, 1, "npm", "-g")
}

log.verbose("cli", process.argv)

var conf = nopt(types, shorthands)
npm.argv = conf.argv.remain
if (npm.deref(npm.argv[0])) npm.command = npm.argv.shift()
else conf.usage = true


if (conf.version) {
  console.log(npm.version)
  return
}

if (conf.versions) {
  npm.command = "version"
  conf.usage = false
  npm.argv = []
}

log.info("using", "npm@%s", npm.version)
log.info("using", "node@%s", process.version)

process.on("uncaughtException", function(err){console.log(err.stack);})

if (conf.usage && npm.command !== "help") {
  npm.argv.unshift(npm.command)
github brackets-userland / brackets-npm-registry / src / node / extension-installer.js View on Github external
function install(targetPath, npmPackageName, loggers) {

  if (runDirectly) {
    loggers = null;
  }

  const npmInstallFolder = path.resolve(targetPath, 'node_modules', npmPackageName);
  const finalInstallFolder = path.resolve(targetPath, npmPackageName);

  const logOutput = loggers ? loggers.output : defaultLogger.output;
  const logProgress = loggers ? loggers.progress : defaultLogger.progress;

  logProgress(`using node ${process.version}, npm ${npm.version}`);
  return Promise.all([execCmd('node --version'), execCmd('npm --version')])
    .then(([nodeVersion, npmVersion]) => {
      logProgress(`node in path version ${nodeVersion}, npm in path version ${npmVersion}`);
      logProgress(`loading npm`);
      return fromNode(npm.load.bind(npm));
    })
    .then(() => {
      // npm is loaded, we can start the installation
      logProgress(`executing npm install ${targetPath} ${npmPackageName}`);
      return fromNode(npm.commands.install.bind(npm.commands, targetPath, npmPackageName));
    })
    .then(() => {
      logProgress('installation successful into directory:\n', npmInstallFolder);
      logProgress('ensuring the target directory exists:\n', finalInstallFolder);
      return fromNode(fs.ensureDir.bind(fs, finalInstallFolder));
    })
github hoodiehq-archive / hoodie-cli / lib / hoodie / version.js View on Github external
VersionCommand.prototype.run = function() {

  var info = 'Version: ' + pkg.version +
    ' (node ' + process.version +
    ', npm ' + npm.version +
    ', platform: ' + process.platform + ')\n';

  console.log(info);
};
github arikon / npm2debian / cli.js View on Github external
flagsDone = (key === '');
    } else if (key) {
        conf[key] = arg;
        key = null;
    } else arglist.push(arg);
}
if (key) conf[key] = true;
npm.argv = arglist;

var vindex = arglist.indexOf('-v')
    , printVersion = vindex !== -1 || conf.version;
if (printVersion) {
    sys.puts(npm2debian.version);
    if (vindex !== -1) arglist.splice(vindex, 1);
} else {
    log('npm@' + npm.version, 'using');
    log('npm2debian@' + npm2debian.version, 'using');
}

process.on('uncaughtException', errorHandler);
process.on('exit', function () {
    if (!itWorked) log.win('not ok');
})

var itWorked = false;


if (!command && !printVersion) conf.usage = true;

if (printVersion) itWorked = true;
else {
    if (conf.usage && command !== 'help') {
github 1602 / compound / lib / server / compound.js View on Github external
rw.app.get('/compound/environment.json', function(req, res) {

        if (rw.app.disabled('env info')) {
            return res.send({forbidden: true});
        }

        try {
            jugglingdbVersion = require('jugglingdb').version;
        } catch (e) {
            jugglingdbVersion = 'not installed';
        }

        try {
            npmVersion = require('npm').version;
        } catch (e) {}

        try {
            viewEngineVersion = require(rw.app.root + '/node_modules/' + rw.app.set('view engine')).version;
        } catch (e) {
            viewEngineVersion = 'not installed';
        }

        res.send({
            settings: rw.app.settings,
            versions: {
                core: process.versions,
                npm: npmVersion,
                compound: rw.version,
                jugglingdb: jugglingdbVersion,
                templating: {