-
-
Notifications
You must be signed in to change notification settings - Fork 92
Expand file tree
/
Copy pathls.js
More file actions
27 lines (20 loc) · 643 Bytes
/
Copy pathls.js
File metadata and controls
27 lines (20 loc) · 643 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
import fs from "node:fs";
import process from "node:process";
const argv = process.argv.slice(2);
const filePaths = argv.filter((arg) => !arg.startsWith("-"));
const showHiddenFiles = argv.includes("-a");
if (filePaths.length > 1) {
console.error("Error: This version only supports one directory path a time.");
process.exit(1);
}
const target = filePaths[0] || ".";
const files = fs.readdirSync(target);
let filteredFIles = files;
if (!showHiddenFiles) {
filteredFIles = files.filter((file) => !file.startsWith("."));
} else {
filteredFIles = [".", "..", ...files];
}
filteredFIles.forEach((file) => {
console.log(file);
});