Glasgow | 25-SDC-NOV | Katarzyna Kazimierczuk | Sprint 3 | Implement Shell Tools#324
Glasgow | 25-SDC-NOV | Katarzyna Kazimierczuk | Sprint 3 | Implement Shell Tools#324katarzynakaz wants to merge 4 commits intoCodeYourFuture:mainfrom
Conversation
SlideGauge
left a comment
There was a problem hiding this comment.
General note: I notced async/await being used here, I have doubts in necessity of it in this context: we're doing a console utility
|
Thank you for the feedback. I was folllowing the coursework in Sp 4 with the use of async / await but I see your point. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
illicitonion
left a comment
There was a problem hiding this comment.
A lot of the pieces here are looking good, but the solutions often aren't very general - can you take a look at these comments? Thanks!
| async function showVisibleInSampleFiles() { | ||
| const listOfFiles = await fs.readdir("sample-files"); |
There was a problem hiding this comment.
We generally don't want to hard-code that our program only works with specific directories - can you think how to make this more general? And how to make it share code with the other two functions?
|
|
||
| if (argv.includes("-l")) { | ||
| await countLines(files); | ||
| } else if (argv.includes("-w")) { |
There was a problem hiding this comment.
The real wc also supports passing multiple of the flags at once (e.g. wc -w -l /some/file), and does something a bit different if you pass multiple files (wc -w -c /some/file /some/other/file) - can you see if you can match those behaviours?
|
|
||
| // * `wc -l sample-files/3.txt` | ||
| // * `wc -l sample-files/*` | ||
| async function countLines(listOfFiles) { |
There was a problem hiding this comment.
These functions are quite repetitive with each other.
| import process from "node:process"; | ||
| import { promises as fs } from "node:fs"; | ||
|
|
||
| //from coursework |
There was a problem hiding this comment.
Please remove the assorted commented out code :)
| if (file === "") { | ||
| console.log(""); | ||
| } else { | ||
| console.log(`${countingOnlyFullLines} ${file}`); |
There was a problem hiding this comment.
These ifs are quite repetitive, which has a couple of issues:
- When reading the code, it's hard to see which parts are the same across the branches, and what parts are different.
- In the future if we add new concerns (e.g. a "colour every other line" flag), we'll need to implement that across each of the branches.
We often solve this by separating "the differences" from "what's the same", e.g.
// Make a variable up-front:
let prefix = "";
// Conditionally change things
if (something) {
prefix = "hello";
} else if (somethingElse) {
prefix = "goodbye";
}
console.log(`${prefix}${line}`);So that the ifs at the start make clear how things are different, and what comes after shows what's the same/different
|
The changed files in this PR don't match what is expected for this task. Please check that you committed the right files for the task, and that there are no accidentally committed files from other sprints. Please review the changed files tab at the top of the page, we are only expecting changes in this directory: If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above. |
1 similar comment
|
The changed files in this PR don't match what is expected for this task. Please check that you committed the right files for the task, and that there are no accidentally committed files from other sprints. Please review the changed files tab at the top of the page, we are only expecting changes in this directory: If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed). If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above. |
There was a problem hiding this comment.
Please can you remove these .DS_Store files from your branch? Thanks!
Self checklist
Changelist
js tools.