Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions lib/commands/birthday.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ const BaseCommand = require('../base-command.js')

class Birthday extends BaseCommand {
async exec () {
this.npm.config.set('package', ['@npmcli/npm-birthday'])
this.npm.config.set('yes', true)
const exec = await this.npm.cmd('exec')
return exec.exec(['npm-birthday'])
return this.npm.exec('exec', ['@npmcli/npm-birthday'])
}
}

Expand Down
30 changes: 8 additions & 22 deletions test/lib/commands/birthday.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,14 @@
const t = require('tap')
const { fake: mockNpm } = require('../../fixtures/mock-npm')
const { real: mockNpm } = require('../../fixtures/mock-npm')

t.test('birthday', async t => {
t.plan(4)
const config = {
yes: false,
package: [],
}
const npm = mockNpm({
config,
cmd: async (cmd) => {
t.ok(cmd, 'exec', 'calls out to exec command')
return {
exec: async (args) => {
t.equal(npm.config.get('yes'), true, 'should say yes')
t.strictSame(npm.config.get('package'), ['@npmcli/npm-birthday'],
'uses correct package')
t.strictSame(args, ['npm-birthday'], 'called with correct args')
},
}
t.plan(2)
const { Npm } = mockNpm(t, {
libnpmexec: ({ args, yes }) => {
t.ok(yes)
t.match(args, ['@npmcli/npm-birthday'])
},
})
const Birthday = require('../../../lib/commands/birthday.js')
const birthday = new Birthday(npm)

await birthday.exec([])
const npm = new Npm()
await npm.exec('birthday', [])
})