There was an error while loading. Please reload this page.
1 parent c8e7c29 commit de8dd1aCopy full SHA for de8dd1a
1 file changed
implement-shell-tools/wc/wc.js
@@ -27,8 +27,21 @@ if (Object.keys(options).length === 0) {
27
// incrementally updated in the loop below
28
const totals = { l: 0, w: 0, c: 0 };
29
30
+// wc actually prints total if there is more than one argument, not more than one file
31
+// e.g. wc invalid.txt valid.txt
32
+// there will be a total line with the same stats are the valid.txt stats
33
let fileCount = 0;
34
+
35
for (const path of paths) {
36
+ //
37
+ try {
38
+ const validPath = fs.statSync(path).isDirectory();
39
+ } catch (err) {
40
+ console.error(`wc: ${path} open: No such file or directory`);
41
+ fileCount++;
42
+ continue;
43
+ }
44
45
if (fs.statSync(path).isDirectory()) {
46
console.eror(`wc: ${path}: read: Is a directory`);
47
} else {
0 commit comments