NW | 26-SDC-Mar | TzeMing Ho | Sprint 3 | Implement shell tools exercises#422
NW | 26-SDC-Mar | TzeMing Ho | Sprint 3 | Implement shell tools exercises#422TzeMingHo wants to merge 15 commits into
Conversation
SlideGauge
left a comment
There was a problem hiding this comment.
I've got a couple of notes from my side could you fix them?
| let count = 1; | ||
|
|
||
| for (let path of pathsArray) { | ||
| const context = await fs.readFile(path, "utf-8"); |
There was a problem hiding this comment.
what will happen if file does not exist?
There was a problem hiding this comment.
I should have added a try/catch, right?
| const lines = context.trimEnd().split("\n"); | ||
| if (options.nonBlank) { | ||
| lines.forEach((line) => { | ||
| if (line.length != 0) { |
There was a problem hiding this comment.
what happens if i got a line consisting of whitespace?
There was a problem hiding this comment.
It would count as a line. So, it added trim on the line.
| const fullPath = `${base.endsWith("/") ? base : base + "/"}${fileName}`; | ||
| const stats = await fs.stat(fullPath); | ||
| if (stats.isDirectory()) { | ||
| return `\x1b[1;34m${fileName}\x1b[0m`; |
There was a problem hiding this comment.
Good idea to use colour output, the only caveat we should output the color only if we are in terminal mode. I.e. right now if I pass it into a pipe, it will output these codes as well
There was a problem hiding this comment.
I attempted to add process.stdout.isTTY in the conditional check.
| let numberOfWords = 0; | ||
| let numberOfCharacters = 0; | ||
|
|
||
| const file = await fs.readFile(path, "utf-8"); |
There was a problem hiding this comment.
I should have added try/catch.
| const options = program.opts(); | ||
|
|
||
| function padStartNumbers(...args) { | ||
| const space = [3, 4, 4]; |
There was a problem hiding this comment.
Should I set all spaces to 8 by default?
Learners, PR Template
Self checklist
Changelist
I have completed the exercises.