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 c58db9c commit eb67a84Copy full SHA for eb67a84
1 file changed
implement-shell-tools/wc/wc.js
@@ -14,13 +14,16 @@ program.parse();
14
const argv = program.args;
15
16
17
-
18
const path = argv[0];
19
20
const options = program.opts();
21
22
23
-const pathInfo = await stat(path);
+
+if (argv.length < 1) {
24
+ console.error("You must pass at least one path!");
25
+ process.exit(1);
26
+}
27
28
function counter(item) {
29
const lines = item.trim().split("\n").length;
@@ -29,6 +32,9 @@ function counter(item) {
32
return { lines, words, characters };
30
33
}
31
34
35
+for (const path of argv) {
36
+ const pathInfo = await stat(path);
37
38
if (pathInfo.isFile()) {
39
const content = await fs.readFile(path, "utf-8");
40
const stats = counter(content);
@@ -52,3 +58,4 @@ if (pathInfo.isFile()) {
52
58
53
59
54
60
61
0 commit comments