Skip to content

Commit 4fb6e2f

Browse files
committed
fix: npm birthday
Replaces usage of flatOptions with npm.config.
1 parent b7b4491 commit 4fb6e2f

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

lib/birthday.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
1-
class Birthday {
2-
constructor (npm) {
3-
this.npm = npm
4-
Object.defineProperty(this.npm, 'flatOptions', {
5-
value: {
6-
...npm.flatOptions,
7-
package: ['@npmcli/npm-birthday'],
8-
yes: true,
9-
},
10-
})
11-
}
1+
const BaseCommand = require('./base-command.js')
122

3+
class Birthday extends BaseCommand {
134
exec (args, cb) {
5+
this.npm.config.set('package', ['@npmcli/npm-birthday'])
6+
this.npm.config.set('yes', true)
147
return this.npm.commands.exec(['npm-birthday'], cb)
158
}
169
}

test/lib/birthday.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
const t = require('tap')
2-
const npm = {
3-
flatOptions: {
4-
yes: false,
5-
package: [],
6-
},
2+
const mockNpm = require('../fixtures/mock-npm')
3+
4+
const config = {
5+
yes: false,
6+
package: [],
7+
}
8+
const npm = mockNpm({
9+
config,
710
commands: {
811
exec: (args, cb) => {
9-
t.equal(npm.flatOptions.yes, true, 'should say yes')
10-
t.strictSame(npm.flatOptions.package, ['@npmcli/npm-birthday'],
12+
t.equal(npm.config.get('yes'), true, 'should say yes')
13+
t.strictSame(npm.config.get('package'), ['@npmcli/npm-birthday'],
1114
'uses correct package')
1215
t.strictSame(args, ['npm-birthday'], 'called with correct args')
1316
t.match(cb, Function, 'callback is a function')
1417
cb()
1518
},
1619
},
17-
}
20+
})
1821

1922
const Birthday = require('../../lib/birthday.js')
2023
const birthday = new Birthday(npm)

0 commit comments

Comments
 (0)