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 1a80d5b commit bdfbbbaCopy full SHA for bdfbbba
1 file changed
implement-shell-tools/wc/wc.js
@@ -27,10 +27,12 @@ if (Object.keys(options).length === 0) {
27
// incrementally updated in the loop below
28
const totals = { l: 0, w: 0, c: 0 };
29
30
+let fileCount = 0;
31
for (const path of paths) {
32
if (fs.statSync(path).isDirectory()) {
33
console.log(`wc: ${path}: read: Is a directory`);
34
} else {
35
+ fileCount++;
36
let outputStr = "";
37
const file = fs.readFileSync(path, "utf-8");
38
if (options.l) {
@@ -63,3 +65,7 @@ for (const path of paths) {
63
65
console.log(outputStr);
64
66
}
67
68
+
69
+if (fileCount > 1) {
70
+ console.log(`\t${totals.l}\t${totals.w}\t${totals.c} total`);
71
+}
0 commit comments