diff --git a/lib/ci.js b/lib/ci.js index 1fbb28b570f6f..375c1448a1ea1 100644 --- a/lib/ci.js +++ b/lib/ci.js @@ -1,7 +1,7 @@ 'use strict' +const npm = require('./npm.js') const Installer = require('libcipm') -const npmConfig = require('./config/figgy-config.js') const npmlog = require('npmlog') ci.usage = 'npm ci' @@ -10,7 +10,13 @@ ci.completion = (cb) => cb(null, []) module.exports = ci function ci (args, cb) { - return new Installer(npmConfig({ log: npmlog })).run().then(details => { + const opts = Object.create({ log: npmlog }) + for (const key in npm.config.list[0]) { + if (key !== 'log') { + opts[key] = npm.config.list[0][key] + } + } + return new Installer(opts).run().then(details => { npmlog.disableProgress() console.log(`added ${details.pkgCount} packages in ${ details.runTime / 1000 diff --git a/test/tap/ci.js b/test/tap/ci.js index 9150f26efeedc..3f3e251d03f1d 100644 --- a/test/tap/ci.js +++ b/test/tap/ci.js @@ -19,6 +19,9 @@ const EXEC_OPTS = { cwd: testDir } const PKG = { name: 'top', version: '1.2.3', + scripts: { + install: 'node -p process.env.npm_config_foo' + }, dependencies: { optimist: '0.6.0', clean: '2.1.6' @@ -77,6 +80,7 @@ test('basic installation', (t) => { .then(() => fixture.create(testDir)) .then(() => common.npm([ 'ci', + '--foo=asdf', '--registry', common.registry, '--loglevel', 'warn' ], EXEC_OPTS)) @@ -88,7 +92,7 @@ test('basic installation', (t) => { t.equal(stderr.trim(), '', 'no output on stderr') t.match( stdout.trim(), - /^added 6 packages in \d+(?:\.\d+)?s$/, + /\nasdf\nadded 6 packages in \d+(?:\.\d+)?s$/, 'no warnings on stderr, and final output has right number of packages' ) return fs.readdirAsync(path.join(testDir, 'node_modules')) @@ -144,6 +148,7 @@ test('supports npm-shrinkwrap.json as well', (t) => { .then(() => fixture.create(testDir)) .then(() => common.npm([ 'ci', + '--foo=asdf', '--registry', common.registry, '--loglevel', 'warn' ], EXEC_OPTS)) @@ -155,7 +160,7 @@ test('supports npm-shrinkwrap.json as well', (t) => { t.equal(stderr.trim(), '', 'no output on stderr') t.match( stdout.trim(), - /^added 6 packages in \d+(?:\.\d+)?s$/, + /\nasdf\nadded 6 packages in \d+(?:\.\d+)?s$/, 'no warnings on stderr, and final output has right number of packages' ) }) @@ -194,6 +199,7 @@ test('removes existing node_modules/ before installing', (t) => { .then(() => fixture.create(testDir)) .then(() => common.npm([ 'ci', + '--foo=asdf', '--registry', common.registry, '--loglevel', 'warn' ], EXEC_OPTS)) @@ -232,6 +238,7 @@ test('errors if package-lock.json missing', (t) => { .then(() => fixture.create(testDir)) .then(() => common.npm([ 'ci', + '--foo=asdf', '--registry', common.registry, '--loglevel', 'warn' ], EXEC_OPTS)) @@ -268,6 +275,7 @@ test('errors if package-lock.json invalid', (t) => { .then(() => fixture.create(testDir)) .then(() => common.npm([ 'ci', + '--foo=asdf', '--registry', common.registry, '--loglevel', 'warn' ], EXEC_OPTS))