• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict'
2
3const npm = require('./npm.js')
4const Installer = require('libcipm')
5const log = require('npmlog')
6const path = require('path')
7const pack = require('./pack.js')
8
9ci.usage = 'npm ci'
10
11ci.completion = (cb) => cb(null, [])
12
13module.exports = ci
14function ci (args, cb) {
15  const opts = {
16    // Add some non-npm-config opts by hand.
17    cache: path.join(npm.config.get('cache'), '_cacache'),
18    // NOTE: npm has some magic logic around color distinct from the config
19    // value, so we have to override it here
20    color: !!npm.color,
21    hashAlgorithm: 'sha1',
22    includeDeprecated: false,
23    log,
24    'npm-session': npm.session,
25    'project-scope': npm.projectScope,
26    refer: npm.referer,
27    dmode: npm.modes.exec,
28    fmode: npm.modes.file,
29    umask: npm.modes.umask,
30    npmVersion: npm.version,
31    tmp: npm.tmp,
32    dirPacker: pack.packGitDep
33  }
34
35  if (npm.config.get('dev')) {
36    log.warn('ci', 'Usage of the `--dev` option is deprecated. Use `--also=dev` instead.')
37  }
38
39  for (const key in npm.config.list[0]) {
40    if (!['log', 'cache'].includes(key)) {
41      opts[key] = npm.config.list[0][key]
42    }
43  }
44
45  return new Installer(opts).run().then(details => {
46    log.disableProgress()
47    console.log(`added ${details.pkgCount} packages in ${
48      details.runTime / 1000
49    }s`)
50  }).then(() => cb(), cb)
51}
52