Skip to content

London | 26-SDC-Mar |Shaghayeghfar | Sprint 3 | Implement-shell-tools#456

Open
shaghayeghfar wants to merge 1 commit into
CodeYourFuture:mainfrom
shaghayeghfar:clean-shell-tools
Open

London | 26-SDC-Mar |Shaghayeghfar | Sprint 3 | Implement-shell-tools#456
shaghayeghfar wants to merge 1 commit into
CodeYourFuture:mainfrom
shaghayeghfar:clean-shell-tools

Conversation

@shaghayeghfar
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

I Implement shell tools in JavaScript with NodeJS.

@shaghayeghfar shaghayeghfar added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. 📅 Sprint 3 Assigned during Sprint 3 of this module labels Apr 1, 2026
Copy link
Copy Markdown

@SlideGauge SlideGauge left a comment

Choose a reason for hiding this comment

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

Good job, there a couple of notes from my side, fix them please


console.log(output.trim());
} catch (err) {
console.error(`wc: cannot open ${file}`);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks like the whole cat.js file has wc tool inside, not cat

continue;
}

console.log(file);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

real ls default output puts all files on one line separated by spaces; one-per-line requires the -1 flag. The -1 flag is not implemented here.

const folder = args.filter((arg) => !arg.startsWith("-"))[0] || ".";

// read directory
const files = fs.readdirSync(folder);
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 happens if no folder is found?

} catch (err) {
console.error(`wc: cannot open ${file}`);
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing totals row for multiple files. When more than one file is given, real wc prints a total line at the end.


// if no flag → show all
if (!showLines && !showWords && !showBytes) {
output = `${lines} ${words} ${bytes} ${file}`;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Numbers are not right-aligned. Real wc uses fixed-width columns

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. 📅 Sprint 3 Assigned during Sprint 3 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants