Glasgow | 26-JUL-SDC | Shreef Ibrahim| Sprint 3 | Implement- shell- tools - #586
Glasgow | 26-JUL-SDC | Shreef Ibrahim| Sprint 3 | Implement- shell- tools#586shreefAhmedM wants to merge 2 commits into
Conversation
SlideGauge
left a comment
There was a problem hiding this comment.
Good job, I left a couple of comments, could you satisfy them?
|
|
||
| output += fileName; | ||
|
|
||
| console.log(output); |
There was a problem hiding this comment.
Try running your wc sample-files/* next to the real wc sample-files/*. How many lines does each print? What does the real tool add at the bottom when you hand it more than one file - and where would that value need to be built up in your loop?
|
|
||
| for (const line of lines) { | ||
|
|
||
| if (flag === "-n") { |
There was a problem hiding this comment.
Put your cat -n sample-files/1.txt beside the real one and look at the space before the 1. What's different about how the number sits in the column? You already solved this exact thing somewhere else in this same file — where?
| else if (flag === "-b") { | ||
|
|
||
| if (line === "") { | ||
| console.log(""); |
There was a problem hiding this comment.
What character does real cat place between the line number and the text — is it spaces, or something else? Try copying a line of real cat -b output and your own into the same file; do they line up?
| console.log(path.basename(target)); | ||
| } else { | ||
|
|
||
| let files = fs.readdirSync(target); |
There was a problem hiding this comment.
Run ls -1 -a sample-files for real and compare it to yours, line by line. Which two entries does the real one list that yours doesn't? Does fs.readdirSync ever return those, and if not, where could they come from?
| let text = fs.readFileSync(fileName, "utf8"); | ||
|
|
||
| let totalLines = text.split("\n").length - 1; | ||
| let totalWords = text.trim().split(/\s+/).length; |
There was a problem hiding this comment.
What would totalWords come out as for a completely empty file, given "".split(/\s+/)? What does real wc report for one? It's not in the test set — but is the count you'd produce the one you'd want?
Learners, PR Template
Self checklist
Changelist
Implemented a simple version of cat, ls and wc commands using Node.js.
Task ID: CYF-1150