Skip to content

Glasgow | 26-JUL-SDC | Shreef Ibrahim| Sprint 3 | Implement- shell- tools - #586

Open
shreefAhmedM wants to merge 2 commits into
CodeYourFuture:mainfrom
shreefAhmedM:implement-shell-tools
Open

Glasgow | 26-JUL-SDC | Shreef Ibrahim| Sprint 3 | Implement- shell- tools#586
shreefAhmedM wants to merge 2 commits into
CodeYourFuture:mainfrom
shreefAhmedM:implement-shell-tools

Conversation

@shreefAhmedM

@shreefAhmedMshreefAhmedM commented Jul 19, 2026

Copy link
Copy Markdown

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

Implemented a simple version of cat, ls and wc commands using Node.js.

Task ID: CYF-1150

@shreefAhmedMshreefAhmedM added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Jul 19, 2026

@SlideGaugeSlideGauge left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job, I left a couple of comments, could you satisfy them?


output += fileName;

console.log(output);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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") {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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("");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@SlideGaugeSlideGauge added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Aug 4, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ReviewedVolunteer to add when completing a review with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@shreefAhmedM@SlideGauge