Skip to content

Commit 3a92500

Browse files
ls -1 implemented
1 parent 8761cb6 commit 3a92500

1 file changed

Lines changed: 6 additions & 15 deletions

File tree

  • implement-shell-tools/ls

implement-shell-tools/ls/ls.js

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { program } from "commander";
2+
import { on } from "node:events";
23
import { promises as fs } from "node:fs";
34
import path from "node:path";
45

@@ -14,24 +15,14 @@ program
1415
program.parse();
1516

1617
const paths = program.args;
18+
const { 1: onePerLine, all } = program.opts();
1719

1820
const directory = paths.length === 0 ? "." : paths[0];
1921

2022
let entries = await fs.readdir(directory);
21-
console.log(entries.join(" "));
2223

24+
if (onePerLine) {
25+
console.log(entries.filter((entry) => entry[0] !== ".").join("\n"));
26+
// entries.filter((entry) => { entry[0] === "." })
27+
}
2328

24-
// entries.forEach((entry) => {
25-
// console.log(entry);
26-
// });
27-
28-
// Read directory entries
29-
// console.log(entries);
30-
// for (const directory of directories) {
31-
32-
// console.log(entries);
33-
// }
34-
35-
// console.log(entries);
36-
37-
// --- Read directory contents ---

0 commit comments

Comments
 (0)