We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b5dedf5 commit 86cfa5aCopy full SHA for 86cfa5a
implement-shell-tools/ls/ls.js
@@ -0,0 +1,27 @@
1
+import process from "node:process";
2
+import { promises as fs } from "node:fs";
3
+
4
+const argv = process.argv.slice(2, process.argv.length);
5
+const currentDir = './';
6
+const flags = [];
7
+let path = '';
8
+for (let i = 0; i < argv.length; i++) {
9
+ if (argv[i][0] == "-") {
10
+ flags.push(argv[i]);
11
+ } else {
12
+ path = argv[i];
13
+ }
14
+}
15
+if (path == '') path = currentDir;
16
17
+const content = await fs.readdir(path);
18
19
+if (flags.includes("-l")) {
20
+ for (let i = 0; i < content.length; i++) {
21
+ let line = content[i];
22
+ if (!flags.includes("-a") && line[0] == ".") continue;
23
+ console.log(line);
24
25
+} else {
26
+ console.log(content.join(" "));
27
0 commit comments