File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,12 +10,14 @@ program
1010 . name ( name )
1111 . description ( description )
1212 . version ( version )
13+ . argument ( '<filename>' , 'the path to file to examine' )
1314 . usage ( '[options] <filename>' )
1415 . option ( '-d, --directory <path>' , 'location of files of supported filetypes' )
1516 . option ( '-c, --require-config <path>' , 'path to a requirejs config' )
1617 . option ( '-w, --webpack-config <path>' , 'path to a webpack config' )
1718 . option ( '-t, --ts-config <path>' , 'path to a typescript config' )
1819 . option ( '--list-form' , 'output the list form of the tree (one element per line)' )
20+ . showHelpAfterError ( )
1921 . parse ( ) ;
2022
2123const cliOptions = program . opts ( ) ;
Original file line number Diff line number Diff line change 1+ import { strict as assert } from 'node:assert' ;
2+ import { spawnSync } from 'node:child_process' ;
3+ import path from 'node:path' ;
4+ import process from 'node:process' ;
5+ import { fileURLToPath } from 'node:url' ;
6+
7+ const testDir = path . dirname ( fileURLToPath ( import . meta. url ) ) ;
8+ const cliPath = path . resolve ( testDir , '..' , 'bin' , 'cli.js' ) ;
9+
10+ describe ( 'dependency-tree CLI' , ( ) => {
11+ it ( 'prints usage and exits when filename is missing' , ( ) => {
12+ const result = spawnSync ( process . execPath , [ cliPath ] , {
13+ encoding : 'utf8'
14+ } ) ;
15+
16+ assert . equal ( result . status , 1 ) ;
17+ assert . match ( result . stderr , / e r r o r : m i s s i n g r e q u i r e d a r g u m e n t ' f i l e n a m e ' / ) ;
18+ assert . match ( result . stderr , / U s a g e : d e p e n d e n c y - t r e e \[ o p t i o n s ] < f i l e n a m e > / ) ;
19+ } ) ;
20+ } ) ;
You can’t perform that action at this time.
0 commit comments