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 4e1c717 commit d2e94fcCopy full SHA for d2e94fc
1 file changed
implement-shell-tools/wc/wc.js
@@ -3,17 +3,17 @@ import { promises as fs } from "node:fs";
3
4
const args = process.argv.slice(2);
5
6
-const path = args[0];
7
-
8
-if (!path) {
9
- console.error("Please provide a file path");
+if (args.length === 0) {
+ console.error("Please provide at least one file");
10
process.exit(1);
11
}
12
13
-const content = await fs.readFile(path, "utf-8");
+for (const path of args) {
+ const content = await fs.readFile(path, "utf-8");
14
15
-const lines = content.split("\n").length;
16
-const words = content.split(" ").length;
17
-const chars = content.length;
+ const lines = content.split("\n").length;
+ const words = content.split(" ").length;
+ const chars = content.length;
18
19
-console.log(lines, words, chars);
+ console.log(lines, words, chars, path);
+}
0 commit comments