Skip to content

Commit e85e714

Browse files
committed
implement ls -1 path
1 parent eaf62b9 commit e85e714

File tree

1 file changed

+8
-4
lines changed
  • implement-shell-tools/ls

1 file changed

+8
-4
lines changed

implement-shell-tools/ls/ls.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import { promises as fs } from "node:fs";
22
async function listDir() {
3-
const fileListArray = await fs.readdir("./");
4-
//console.log(fileListArray);
5-
const flag = process.argv[2];
6-
const fileNamePattern = process.argv[3];
3+
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+
console.log(fileListArray);
9+
10+
711
for(const item of fileListArray){
812
console.log(item);
913
}

0 commit comments

Comments
 (0)