File tree Expand file tree Collapse file tree 2 files changed +15
-19
lines changed Expand file tree Collapse file tree 2 files changed +15
-19
lines changed Original file line number Diff line number Diff line change 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}
Original file line number Diff line number Diff line change 11const 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
1922const Birthday = require ( '../../lib/birthday.js' )
2023const birthday = new Birthday ( npm )
You can’t perform that action at this time.
0 commit comments