Skip to content

Commit

Permalink
ci: pass all configs to cipm installer
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Aug 12, 2019
1 parent ab66c9a commit 8b43c96
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
10 changes: 8 additions & 2 deletions lib/ci.js
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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
Expand Down
12 changes: 10 additions & 2 deletions test/tap/ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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))
Expand All @@ -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'))
Expand Down Expand Up @@ -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))
Expand All @@ -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'
)
})
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 8b43c96

Please sign in to comment.