Skip to content

Commit 248f9de

Browse files
committed
match required commends exactly
1 parent 6c2dcfa commit 248f9de

1 file changed

Lines changed: 6 additions & 20 deletions

File tree

  • implement-shell-tools/ls

implement-shell-tools/ls/ls.mjs

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,12 @@ const path = program.args[0] || ".";
1414
const options = program.opts();
1515
try {
1616
const files = await fs.readdir(path);
17-
if (options.onePerLine && options.a) {
18-
for (const file of files) {
19-
console.log(file);
20-
}
21-
} else if (options.onePerLine) {
22-
for (const file of files) {
23-
if (!file.startsWith(".")) {
24-
console.log(file);
25-
}
26-
}
27-
} else if (options.a) {
28-
for (const file of files) {
29-
process.stdout.write(file + " ");
30-
}
31-
} else {
32-
for (const file of files) {
33-
if (!file.startsWith(".")) {
34-
process.stdout.write(file + " ");
35-
}
36-
}
17+
18+
for(const file of files)
19+
{
20+
if(!options.a && file.startsWith("."))continue;
21+
22+
console.log(file);
3723
}
3824
} catch (error) {
3925
console.error(error.message);

0 commit comments

Comments
 (0)