Skip to content

Commit b6fdd20

Browse files
committed
Edit and removed unnecessary lines.
1 parent 1160111 commit b6fdd20

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

implement-shell-tools/wc/MyWc.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { program } from "commander";
22
import { promises as fs } from "node:fs";
3-
import process from "node:process";
43

54
program
6-
.name("myLs")
7-
.description("my ls clone")
5+
.name("myWc")
6+
.description("my wc clone")
87
.option("-l", "line count")
98
.option("-w", "words count")
109
.option("-c", "character count")
@@ -26,7 +25,6 @@ let totalWords = 0;
2625
if (opts.l) {
2726
for (const file of files) {
2827
const content = await fs.readFile(file, "utf-8");
29-
console.log(content);
3028
const lineCount = content.split("\n").length;
3129

3230
totalLines += lineCount;
@@ -36,7 +34,6 @@ if (opts.l) {
3634
if (opts.w) {
3735
for (const file of files) {
3836
const content = await fs.readFile(file, "utf-8");
39-
console.log(content);
4037

4138
const wordCount = content.trim().split(/\s+/).length;
4239
totalWords += wordCount;
@@ -49,10 +46,7 @@ if (opts.c) {
4946
const content = await fs.readFile(file, "utf-8");
5047

5148
totalChars += content.trim().length;
52-
// const charList = content.trim().split(/\s+/);
53-
// for (const char of charList) {
54-
// totalChars += char.length;
55-
// }
49+
5650
}
5751
console.log("Total characters:", totalChars);
5852
}

0 commit comments

Comments
 (0)