<commit_before>#!/usr/bin/env node
// Patch the global fs module here at the app level
import fs = require('fs')
import gfs = require('graceful-fs')

gfs.gracefulify(fs)

import loudRejection = require('loud-rejection')
loudRejection()
import path = require('path')
import camelcase = require('camelcase')
import isCI = require('is-ci')
import {stripIndent} from 'common-tags'
import nopt = require('nopt')
import R = require('ramda')
import npm = require('npm')
import npmDefaults = require('npm/lib/config/defaults')
import '../logging/fileLogger'
import pkg from '../pnpmPkgJson'
import * as pnpmCmds from '../cmd'
import runNpm from '../cmd/runNpm'
import initReporter from '../reporter'
import getCommandFullName from '../getCommandFullName'
import checkForUpdates from '../checkForUpdates'

pnpmCmds['install-test'] = pnpmCmds.installTest

const supportedCmds = new Set([
  'add',
  'install',
  'uninstall',
  'update',
  'link',
  'prune',
  'install-test',
  'run',
  'store',
  'list',
  'dislink',
  'help',
  'root',
  'outdated',
])

async function run (argv: string[]) {
  const pnpmTypes = {
    'store': path,
    'store-path': path, // DEPRECATE! store should be used
    'global-path': path,
    'network-concurrency': Number,
    'fetching-concurrency': Number,
    'lock-stale-duration': Number,
    'lock': Boolean,
    'child-concurrency': Number,
    'offline': Boolean,
    'reporter': String,
    'independent-leaves': Boolean,
    'verify-store-integrity': Boolean,
  }
  const types = R.merge(npmDefaults.types, pnpmTypes)
  const cliConf = nopt(
    types,
    npmDefaults.shorthands,
    argv,
    0 // argv should be already sliced by now
  )

  if (cliConf.version) {
    console.log(pkg.version)
    return
  }

  if (!isCI) {
    checkForUpdates()
  }

  const cmd = getCommandFullName(cliConf.argv.remain[0]) || 'help'
  if (!supportedCmds.has(cmd)) {
    runNpm(argv)
    return Promise.resolve()
  }

  if (cliConf['dry-run']) {
    console.error(`Error: 'dry-run' is not supported yet, sorry!`)
    process.exit(1)
  }

  cliConf.save = cliConf.save || !cliConf.saveDev && !cliConf.saveOptional
  if (!cliConf['user-agent']) {
    cliConf['user-agent'] = `${pkg.name}/${pkg.version} npm/? node/${process.version} ${process.platform} ${process.arch}`
  }

  await new Promise((resolve, reject) => {
    npm.load(cliConf as any, (err: Error) => { // tslint:disable-line
      if (err) {
        reject(err)
        return
      }
      resolve()
    })
  })

  const silent = npm.config.get('loglevel') === 'silent' || !npm.config.get('reporter') && isCI

  const opts = R.fromPairs(<any>R.keys(types).map(configKey => [camelcase(configKey), npm.config.get(configKey)])) // tslint:disable-line
  opts.rawNpmConfig = Object.assign.apply(Object, npm.config['list'].reverse())
  opts.bin = npm.bin
  opts.globalBin = npm.globalBin
  opts.globalPrefix = path.join(npm['globalPrefix'], 'pnpm-global')
  opts.prefix = opts.global ? opts.globalPrefix : npm.prefix
  opts.packageManager = pkg

  initReporter(silent ? 'silent' : (<any>opts.reporter || 'default')) // tslint:disable-line

  // `pnpm install ""` is going to be just `pnpm install`
  const cliArgs = cliConf.argv.remain.slice(1).filter(Boolean)
  return pnpmCmds[cmd](cliArgs, opts, cliConf.argv.remain[0])
}

export = run

import errorHandler from '../err'<commit_msg>fix: mute npm output when running with --force<commit_after>#!/usr/bin/env node
// Patch the global fs module here at the app level
import fs = require('fs')
import gfs = require('graceful-fs')

gfs.gracefulify(fs)

import loudRejection = require('loud-rejection')
loudRejection()
import path = require('path')
import camelcase = require('camelcase')
import isCI = require('is-ci')
import {stripIndent} from 'common-tags'
import nopt = require('nopt')
import R = require('ramda')
import npm = require('npm')
import npmDefaults = require('npm/lib/config/defaults')
import '../logging/fileLogger'
import pkg from '../pnpmPkgJson'
import * as pnpmCmds from '../cmd'
import runNpm from '../cmd/runNpm'
import initReporter from '../reporter'
import getCommandFullName from '../getCommandFullName'
import checkForUpdates from '../checkForUpdates'

pnpmCmds['install-test'] = pnpmCmds.installTest

const supportedCmds = new Set([
  'add',
  'install',
  'uninstall',
  'update',
  'link',
  'prune',
  'install-test',
  'run',
  'store',
  'list',
  'dislink',
  'help',
  'root',
  'outdated',
])

async function run (argv: string[]) {
  const pnpmTypes = {
    'store': path,
    'store-path': path, // DEPRECATE! store should be used
    'global-path': path,
    'network-concurrency': Number,
    'fetching-concurrency': Number,
    'lock-stale-duration': Number,
    'lock': Boolean,
    'child-concurrency': Number,
    'offline': Boolean,
    'reporter': String,
    'independent-leaves': Boolean,
    'verify-store-integrity': Boolean,
  }
  const types = R.merge(npmDefaults.types, pnpmTypes)
  const cliConf = nopt(
    types,
    npmDefaults.shorthands,
    argv,
    0 // argv should be already sliced by now
  )

  if (cliConf.version) {
    console.log(pkg.version)
    return
  }

  if (!isCI) {
    checkForUpdates()
  }

  const cmd = getCommandFullName(cliConf.argv.remain[0]) || 'help'
  if (!supportedCmds.has(cmd)) {
    runNpm(argv)
    return Promise.resolve()
  }

  if (cliConf['dry-run']) {
    console.error(`Error: 'dry-run' is not supported yet, sorry!`)
    process.exit(1)
  }

  cliConf.save = cliConf.save || !cliConf.saveDev && !cliConf.saveOptional
  if (!cliConf['user-agent']) {
    cliConf['user-agent'] = `${pkg.name}/${pkg.version} npm/? node/${process.version} ${process.platform} ${process.arch}`
  }
  const force = cliConf['force'] === true
  // removing force to avoid redundant logs from npm
  // see issue #878 and #877
  delete cliConf['force']

  await new Promise((resolve, reject) => {
    npm.load(cliConf as any, (err: Error) => { // tslint:disable-line
      if (err) {
        reject(err)
        return
      }
      resolve()
    })
  })

  const silent = npm.config.get('loglevel') === 'silent' || !npm.config.get('reporter') && isCI

  const opts = R.fromPairs(<any>R.keys(types).map(configKey => [camelcase(configKey), npm.config.get(configKey)])) // tslint:disable-line
  opts.rawNpmConfig = Object.assign.apply(Object, npm.config['list'].reverse())
  opts.bin = npm.bin
  opts.globalBin = npm.globalBin
  opts.globalPrefix = path.join(npm['globalPrefix'], 'pnpm-global')
  opts.prefix = opts.global ? opts.globalPrefix : npm.prefix
  opts.packageManager = pkg
  opts.force = force

  initReporter(silent ? 'silent' : (<any>opts.reporter || 'default')) // tslint:disable-line

  // `pnpm install ""` is going to be just `pnpm install`
  const cliArgs = cliConf.argv.remain.slice(1).filter(Boolean)
  return pnpmCmds[cmd](cliArgs, opts, cliConf.argv.remain[0])
}

export = run

import errorHandler from '../err'
{'fraction_non_alphanumeric': 0.16161178509532062, 'fraction_numerical': 0.002310803004043905, 'mean_word_length': 3.752916952642416, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7412577', 'n_tokens_mistral': 2447, 'n_tokens_neox': 2367, 'n_words': 541}