Skip to content

Commit

Permalink
fixup! fix: show more information during publish dry-run
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys authored and fritzy committed Apr 13, 2022
1 parent 2545065 commit e992b4a
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions test/lib/commands/publish.js
Expand Up @@ -227,6 +227,18 @@ t.test(
),
})

const npm = mockNpm({
config: { 'dry-run': true, loglevel: 'info' },
output: () => {
t.pass('output fn is called')
},
}, t)
const registry = npm.config.get('registry')
npm.config.getCredentialsByURI = uri => {
t.same(uri, registry, 'gets credentials for expected registry')
return { /* no token will call log.warn */ }
}

const Publish = t.mock('../../../lib/commands/publish.js', {
'../../../lib/utils/tar.js': {
getContents: () => ({
Expand All @@ -235,23 +247,19 @@ t.test(
logTar: () => {
t.pass('logTar is called')
},
'proc-log': {
warn (_, msg) {
t.match(msg,
`This command requires you to be logged in to ${registry} (dry-run)`)
},
},
},
libnpmpublish: {
publish: () => {
throw new Error('should not call libnpmpublish in dry run')
},
},
})
const npm = mockNpm({
config: { 'dry-run': true, loglevel: 'info' },
output: () => {
t.pass('output fn is called')
},
}, t)
npm.config.getCredentialsByURI = uri => {
t.same(uri, npm.config.get('registry'), 'gets credentials for expected registry')
return { token: 'some.registry.token' }
}

const publish = new Publish(npm)

Expand Down

0 comments on commit e992b4a

Please sign in to comment.