Exemple #1
0
function enOrDisAbleProgress() {
	if (nrTrackers > 0) {
		log.enableProgress();
	} else {
		log.disableProgress();
	}
}
Exemple #2
0
    .on('response', function(response) {
      var length = parseInt(response.headers['content-length'], 10);
      var progress = log.newItem('', length);

      if (successful(response)) {
        response.pipe(fs.createWriteStream(dest));
      }

      // The `progress` is true by default. However if it has not
      // been explicitly set it's `undefined` which is considered
      // as far as npm is concerned.
      if (process.env.npm_config_progress === 'true') {
        log.enableProgress();

        response.on('data', function(chunk) {
          progress.completeWork(chunk.length);
        })
        .on('end', progress.finish);
      }
    });
Exemple #3
0
 function procError (er) {
   if (progressEnabled) log.enableProgress()
   if (er) {
     log.info('lifecycle', logid(pkg, stage), 'Failed to exec ' + stage + ' script')
     er.message = pkg._id + ' ' + stage + ': `' + cmd + '`\n' +
                  er.message
     if (er.code !== 'EPERM') {
       er.code = 'ELIFECYCLE'
     }
     fs.stat(npm.dir, function (statError, d) {
       if (statError && statError.code === 'ENOENT' && npm.dir.split(path.sep).slice(-1)[0] === 'node_modules') {
         log.warn('', 'Local package.json exists, but node_modules missing, did you mean to install?')
       }
     })
     er.pkgid = pkg._id
     er.stage = stage
     er.script = cmd
     er.pkgname = pkg.name
   }
   process.removeListener('SIGTERM', procKill)
   return cb(er)
 }
Exemple #4
0
      npmconf.load(cli, builtin, function (er, config) {
        if (er === config) er = null

        npm.config = config
        if (er) return cb(er)

        // if the 'project' config is not a filename, and we're
        // not in global mode, then that means that it collided
        // with either the default or effective userland config
        if (!config.get('global') &&
            config.sources.project &&
            config.sources.project.type !== 'ini') {
          log.verbose(
            'config',
            'Skipping project config: %s. (matches userconfig)',
            config.localPrefix + '/.npmrc'
          )
        }

        // Include npm-version and node-version in user-agent
        var ua = config.get('user-agent') || ''
        ua = ua.replace(/\{node-version\}/gi, process.version)
        ua = ua.replace(/\{npm-version\}/gi, npm.version)
        ua = ua.replace(/\{platform\}/gi, process.platform)
        ua = ua.replace(/\{arch\}/gi, process.arch)
        config.set('user-agent', ua)

        var color = config.get('color')

        log.level = config.get('loglevel')
        log.heading = config.get('heading') || 'npm'
        log.stream = config.get('logstream')

        switch (color) {
          case 'always':
            log.enableColor()
            npm.color = true
            break
          case false:
            log.disableColor()
            npm.color = false
            break
          default:
            if (process.stdout.isTTY) npm.color = true
            else if (!tty.isatty) npm.color = true
            else if (tty.isatty(1)) npm.color = true
            else npm.color = false
            break
        }

        if (config.get('unicode')) {
          log.enableUnicode()
        } else {
          log.disableUnicode()
        }

        if (config.get('progress') && (process.stderr.isTTY || (tty.isatty && tty.isatty(2)))) {
          log.enableProgress()
        } else {
          log.disableProgress()
        }

        log.resume()

        // at this point the configs are all set.
        // go ahead and spin up the registry client.
        npm.registry = new CachingRegClient(npm.config)

        var umask = npm.config.get('umask')
        npm.modes = {
          exec: parseInt('0777', 8) & (~umask),
          file: parseInt('0666', 8) & (~umask),
          umask: umask
        }

        var gp = Object.getOwnPropertyDescriptor(config, 'globalPrefix')
        Object.defineProperty(npm, 'globalPrefix', gp)

        var lp = Object.getOwnPropertyDescriptor(config, 'localPrefix')
        Object.defineProperty(npm, 'localPrefix', lp)

        return cb(null, npm)
      })
Exemple #5
0
function genMainPage(issues) {
  return mainPageTemplate({
    issues: issues
  });
};

function genIssuePage(issue) {
  return isocppWiki.writePage({
    name: issue.pageName,
    parent: 'LibraryEvolutionWorkingGroup',
    content: issuePageTemplate({issue: issue}),
    dryrun: argv.dryrun,
  });
};

log.enableProgress();
isocppWiki.login().then(function() {
  return isocppIssues.lewgPlate();
}).then(function(issues) {
  return Promise.all(issues.map(elaborateIssue));
}).then(function(issues) {
  let collator = new Intl.Collator('en');
  issues.sort((a,b) => {
    if (a.priority != b.priority) return a.priority - b.priority;
    return collator.compare(a.pageName, b.pageName);
  });
  console.log(genMainPage(issues));
  var writes = [];
  for (let issue of issues) {
    writes.push(genIssuePage(issue).catch(function(err) {
      log.error('', 'Failed to write issue ' + issue.id + ': ' + (err.stack || err));
Exemple #6
0
      npmconf.load(cli, builtin, function (er, config) {
        if (er === config) er = null

        npm.config = config
        if (er) return cb(er)

        // if the 'project' config is not a filename, and we're
        // not in global mode, then that means that it collided
        // with either the default or effective userland config
        if (!config.get('global') &&
            config.sources.project &&
            config.sources.project.type !== 'ini') {
          log.verbose(
            'config',
            'Skipping project config: %s. (matches userconfig)',
            config.localPrefix + '/.npmrc'
          )
        }

        // Include npm-version and node-version in user-agent
        var ua = config.get('user-agent') || ''
        ua = ua.replace(/\{node-version\}/gi, process.version)
        ua = ua.replace(/\{npm-version\}/gi, npm.version)
        ua = ua.replace(/\{platform\}/gi, process.platform)
        ua = ua.replace(/\{arch\}/gi, process.arch)
        config.set('user-agent', ua)

        if (config.get('metrics-registry') == null) {
          config.set('metrics-registry', config.get('registry'))
        }

        var color = config.get('color')

        log.level = config.get('loglevel')
        log.heading = config.get('heading') || 'npm'
        log.stream = config.get('logstream')

        switch (color) {
          case 'always':
            log.enableColor()
            npm.color = true
            break
          case false:
            log.disableColor()
            npm.color = false
            break
          default:
            if (process.stdout.isTTY) npm.color = true
            else if (!tty.isatty) npm.color = true
            else if (tty.isatty(1)) npm.color = true
            else npm.color = false
            break
        }

        if (config.get('unicode')) {
          log.enableUnicode()
        } else {
          log.disableUnicode()
        }

        if (config.get('progress') && (process.stderr.isTTY || (tty.isatty && tty.isatty(2)))) {
          log.enableProgress()
        } else {
          log.disableProgress()
        }

        glob(path.resolve(npm.cache, '_logs', '*-debug.log'), function (er, files) {
          if (er) return cb(er)

          while (files.length >= npm.config.get('logs-max')) {
            rimraf.sync(files[0])
            files.splice(0, 1)
          }
        })

        log.resume()

        var umask = npm.config.get('umask')
        npm.modes = {
          exec: parseInt('0777', 8) & (~umask),
          file: parseInt('0666', 8) & (~umask),
          umask: umask
        }

        var gp = Object.getOwnPropertyDescriptor(config, 'globalPrefix')
        Object.defineProperty(npm, 'globalPrefix', gp)

        var lp = Object.getOwnPropertyDescriptor(config, 'localPrefix')
        Object.defineProperty(npm, 'localPrefix', lp)

        config.set('scope', scopeifyScope(config.get('scope')))
        npm.projectScope = config.get('scope') ||
         scopeifyScope(getProjectScope(npm.prefix))

        // at this point the configs are all set.
        // go ahead and spin up the registry client.
        lazyProperty(npm, 'registry', function () {
          registryLoaded = true
          var CachingRegClient = require('./cache/caching-client.js')
          var registry = new CachingRegClient(npm.config)
          registry.version = npm.version
          registry.refer = registryRefer
          return registry
        })

        startMetrics()

        return cb(null, npm)
      })