@@ -2297,14 +2297,15 @@ describe('Command', () => {
22972297 } )
22982298 . parse ( )
22992299 ) ;
2300- commandObject . should . have
2301- . property ( 'command' )
2300+
2301+ expect ( commandObject )
2302+ . to . have . property ( 'command' )
23022303 . and . equal ( 'dream [command] [opts]' ) ;
2303- commandObject . should . have
2304- . property ( 'desc' )
2304+ expect ( commandObject )
2305+ . to . have . property ( 'desc' )
23052306 . and . equal ( 'Go to sleep and dream' ) ;
2306- commandObject . should . have . property ( 'builder' ) ;
2307- commandObject . should . have . property ( 'handler' ) ;
2307+ expect ( commandObject ) . to . have . property ( 'builder' ) ;
2308+ expect ( commandObject ) . to . have . property ( 'handler' ) ;
23082309 pathToFile . should . contain ( join ( 'test' , 'fixtures' , 'cmddir' , 'dream.js' ) ) ;
23092310 filename . should . equal ( 'dream.js' ) ;
23102311 r . exit . should . equal ( true ) ;
@@ -2498,5 +2499,36 @@ describe('Command', () => {
24982499 ' --version Show version number [boolean]' ,
24992500 ] ) ;
25002501 } ) ;
2502+
2503+ it ( 'allows ESM modules commands to be extensible using visit option' , ( ) => {
2504+ const r = checkOutput ( ( ) =>
2505+ yargs ( 'remote --help' )
2506+ . wrap ( null )
2507+ . commandDir ( 'fixtures/esm-command' , {
2508+ visit ( _commandObject , _pathToFile , _filename ) {
2509+ if ( ! _commandObject . middlewares ) {
2510+ _commandObject . middlewares = [ ] ;
2511+ }
2512+ return true ;
2513+ } ,
2514+ } )
2515+ . parse ( )
2516+ ) ;
2517+ r . exit . should . equal ( true ) ;
2518+ r . errors . length . should . equal ( 0 ) ;
2519+ r . logs
2520+ . join ( '\n' )
2521+ . split ( / \n + / )
2522+ . should . deep . equal ( [
2523+ 'usage remote <command>' ,
2524+ 'Manage set of tracked repos' ,
2525+ 'Commands:' ,
2526+ ' usage remote add <name> <url> Add remote named <name> for repo at url <url>' ,
2527+ ' usage remote prune <name> [names..] Delete tracked branches gone stale for remotes' ,
2528+ 'Options:' ,
2529+ ' --help Show help [boolean]' ,
2530+ ' --version Show version number [boolean]' ,
2531+ ] ) ;
2532+ } ) ;
25012533 } ) ;
25022534} ) ;
0 commit comments