forked from CodeYourFuture/Module-Tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathls.js
More file actions
32 lines (22 loc) · 596 Bytes
/
Copy pathls.js
File metadata and controls
32 lines (22 loc) · 596 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import process from "node:process";
import { promises as fs } from "node:fs";
const args = process.argv.slice(2);
let showAll = false;
let path = ".";
for (const arg of args) {
if (arg === "-a") {
showAll = true;
} else if (arg === "-1") {
// do nothing: already printing one file per line
path = arg;
}
}
const files = await fs.readdir(path);
for (const file of files) {
if (!showAll && file.startsWith(".")) {
continue;
}
console.log(file);
}
// We already print one file per line because
// console.log(file) automatically puts each file on its own line.