File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { program } from "commander" ;
22import { promises as fs } from "node:fs" ;
3- import process from "node:process" ;
43
54program
65 . name ( "myLs" )
76 . description ( "my ls clone" )
8- . option ( "-1" , "one entry per line" )
7+ . option ( "-1, --one-per-line " , "one entry per line" )
98 . option ( "-a" , "show hidden files" )
109 . argument ( "[paths...]" , "file or directory paths" ) ;
1110
@@ -19,14 +18,14 @@ if (paths.length === 0) {
1918}
2019
2120for ( const path of paths ) {
22- const entries = await fs . readdir ( path ) ;
21+ const directoryItems = await fs . readdir ( path ) ;
2322
24- for ( const file of entries ) {
23+ for ( const file of directoryItems ) {
2524 if ( ! opts . a && file . startsWith ( "." ) ) {
2625 continue ;
2726 }
2827
29- if ( opts [ "1" ] ) {
28+ if ( opts . onePerLine ) {
3029 console . log ( file ) ;
3130 } else {
3231 console . log ( file + " " ) ;
You can’t perform that action at this time.
0 commit comments