Skip to content

Commit 1160111

Browse files
committed
Change param
1 parent 830d197 commit 1160111

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

implement-shell-tools/ls/myLs.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { program } from "commander";
22
import { promises as fs } from "node:fs";
3-
import process from "node:process";
43

54
program
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

2120
for (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 + " ");

0 commit comments

Comments
 (0)