Skip to content

Commit 3cc8aaf

Browse files
committed
code now handles no flag cases for all scenarios (file or dir)
1 parent c32410a commit 3cc8aaf

File tree

1 file changed

+9
-3
lines changed
  • implement-shell-tools/wc

1 file changed

+9
-3
lines changed

implement-shell-tools/wc/wc.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ if (pathInfo.isFile()) {
4747
console.log(`${stats.lines} ${path}`);
4848
} else if (options.word) {
4949
console.log(`${stats.words} ${path}`);
50-
} else {
50+
} else if (options.character) {
5151
console.log(`${stats.characters} ${path}`);
52+
} else {
53+
console.log(` ${stats.lines} ${stats.words} ${stats.characters} ${path}`);
5254
}
5355

5456
totalLines += stats.lines;
@@ -67,8 +69,10 @@ if (pathInfo.isFile()) {
6769
console.log(`${stats.lines} ${filePath}`);
6870
} else if (options.word) {
6971
console.log(`${stats.words} ${filePath}`);
72+
} else if (options.character) {
73+
console.log(`${stats.characters} ${filePath}`);
7074
} else {
71-
console.log(`${stats.characters} ${filePath}`);
75+
console.log(` ${stats.lines} ${stats.words} ${stats.characters} ${path}`);
7276
}
7377

7478
totalLines += stats.lines;
@@ -85,7 +89,9 @@ if (fileCount > 1) {
8589
console.log(`${totalLines} total`);
8690
} else if (options.word) {
8791
console.log(`${totalWords} total`);
88-
} else {
92+
} else if (options.character) {
8993
console.log(`${totalCharacters} total`);
94+
} else {
95+
console.log(` ${stats.lines} ${stats.words} ${stats.characters} ${path}`);
9096
}
9197
}

0 commit comments

Comments
 (0)