File tree Expand file tree Collapse file tree 1 file changed +17
-8
lines changed
Expand file tree Collapse file tree 1 file changed +17
-8
lines changed Original file line number Diff line number Diff line change 11import { promises as fs } from "node:fs" ;
22async function listDir ( ) {
3+ let finalFileList ;
34 const flag = process . argv [ 2 ] ;
4- const fileNamePattern = process . argv [ 3 ] || process . cwd ( ) ;
5- //console.log(fileNamePattern);
6- //console.log(flag);
7- const fileListArray = await fs . readdir ( fileNamePattern ) ;
8- const visibleFileListArray = fileListArray . filter ( file => ! file . startsWith ( '.' ) ) ;
9- //console.log(fileListArray);
10- //console.log(visibleFileListArray);
5+ const argvArray = process . argv . slice ( 2 ) ;
116
12- for ( const item of visibleFileListArray ) {
7+ const flags = argvArray . filter ( item => item . startsWith ( '-' ) ) ;
8+
9+ const Path =
10+ argvArray . filter ( ( item ) => ! item . startsWith ( "-" ) ) || process . cwd ( ) ;
11+
12+ const fileListArray = await fs . readdir ( Path [ 0 ] || process . cwd ( ) ) ;
13+ if ( flags . includes ( '-a' ) ) {
14+ finalFileList = fileListArray ;
15+ } else {
16+ finalFileList = fileListArray . filter ( file => ! file . startsWith ( '.' ) ) ;
17+ }
18+
19+
20+
21+ for ( const item of finalFileList ) {
1322 console . log ( item ) ;
1423 }
1524
You can’t perform that action at this time.
0 commit comments