Skip to content

Commit d2daa0e

Browse files
committed
remove redantant and repetitive code
1 parent e155672 commit d2daa0e

File tree

1 file changed

+1
-8
lines changed
  • implement-shell-tools/wc

1 file changed

+1
-8
lines changed

implement-shell-tools/wc/wc.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,9 @@ program.parse();
1515

1616
const argv = program.args;
1717

18-
const path = argv[0];
19-
2018
const options = program.opts();
2119

2220

23-
if (argv.length < 1) {
24-
console.error("You must pass at least one path!");
25-
process.exit(1);
26-
}
27-
2821
function counter(item) {
2922
const lines = item.trim().split("\n").length;
3023
const words = item.split(/\s+/).filter(Boolean).length;
@@ -72,7 +65,7 @@ if (pathInfo.isFile()) {
7265
} else if (options.character) {
7366
console.log(`${stats.characters} ${filePath}`);
7467
} else {
75-
console.log(`${stats.lines} ${stats.words} ${stats.characters} ${path}`);
68+
console.log(`${stats.lines} ${stats.words} ${stats.characters} ${filePath}`);
7669
}
7770

7871
totalLines += stats.lines;

0 commit comments

Comments
 (0)