Skip to content

Commit c6aa7ae

Browse files
committed
for dir case: create logic to handdle when -l option is added to the prgoram
1 parent 091692c commit c6aa7ae

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

  • implement-shell-tools/wc

implement-shell-tools/wc/wc.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@ if (pathInfo.isFile()) {
4747
for (const file of files) {
4848
const filePath = `${path}/${file}`;
4949
const fileContent = await fs.readFile(filePath, "utf-8");
50-
const stats = counter(fileContent)
50+
const stats = counter(fileContent);
51+
52+
if (options.line) {
53+
console.log(`${stats.lines} ${filePath}`);
54+
} else {
55+
console.log(`${stats.lines} ${stats.words} ${stats.chars} ${fileContent}`);
56+
}
5157
}
5258
}
5359

0 commit comments

Comments
 (0)