Skip to content

Glasgow | 25-SDC-NOV | Katarzyna Kazimierczuk | Sprint 4 | Implement Shell Tools#324

Open
katarzynakaz wants to merge 1 commit intoCodeYourFuture:mainfrom
katarzynakaz:implement-shell-tools-fixed
Open

Glasgow | 25-SDC-NOV | Katarzyna Kazimierczuk | Sprint 4 | Implement Shell Tools#324
katarzynakaz wants to merge 1 commit intoCodeYourFuture:mainfrom
katarzynakaz:implement-shell-tools-fixed

Conversation

@katarzynakaz
Copy link

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

js tools.

@katarzynakaz katarzynakaz added 📅 Sprint 3 Assigned during Sprint 3 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Feb 7, 2026
@katarzynakaz katarzynakaz changed the title Glasgow | 25-SDC-NOV | Katarzyna Kazimierczuk | Sprint 3 | Implement Shell Tools Glasgow | 25-SDC-NOV | Katarzyna Kazimierczuk | Sprint 4 | Implement Shell Tools Feb 7, 2026
@katarzynakaz katarzynakaz added 📅 Sprint 4 Assigned during Sprint 4 of this module and removed 📅 Sprint 3 Assigned during Sprint 3 of this module labels Feb 8, 2026
@SlideGauge SlideGauge added the Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. label Feb 15, 2026
Copy link

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

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


const argv = process.argv.slice(2);

switch (argv[0]) {

Choose a reason for hiding this comment

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

What is here is "pattern matching" of the cases from the task. Whilst it work for these cases, this is unfortunately not the way how production software is written.
Several moments:

  1. functions are referring to some "cases". It is not clear what they mean. Instead, function naming should reflect what the function does: output lines, output lines with numbering etc
  2. Hint: the code in all three functions has a lot of similarities: we read list of files, traverse the list one by one, apply some rule to the line (or no rule at all) and then output the line to console. Can we generalise this somehow, like have a function whose responsibility is to traverse the input list, then the function which reads the file and applies the rules? Try it. (hint: maybe usage of functions as objects passed into initial function may help)

@@ -0,0 +1,46 @@
import process from "node:process";
import { promises as fs } from "node:fs";
// const fs = promises

Choose a reason for hiding this comment

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

This file looks like unnecessary



//one for 1 and 3
async function printOneOrMore(listOfFiles) {

Choose a reason for hiding this comment

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

Nice that all functions are generalised to work with a list, instead (one function for single file, another function is for a list)

// 2 * `cat -n sample-files/1.txt`
// 4 * `cat -n sample-files/*.txt`

async function caseTwoAndFour(listOfFiles) {

Choose a reason for hiding this comment

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

Overall, we do not need async/await pattern in the cat-like utility. We just sequentially read file line by line and at the same time the utility is a console utility

} else if (argv.includes('sample-files')) {
await showVisibleInSampleFiles();
} else {
await showCurrentDir();

Choose a reason for hiding this comment

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

There is no such a function in this file

// 4 * `cat -n sample-files/*.txt`

async function caseTwoAndFour(listOfFiles) {
for (const file of listOfFiles) {

Choose a reason for hiding this comment

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

cat -n with multiple files should continue line numbering across files — i.e., if file 1 has 3 lines, file 2 starts at line 4. Currently numbering restarts at 1 per file. You'd need to track a counter outside the for loop.

function countHelper(inputFiles) {
return {
lines: inputFiles.split('\n').length - 1,
words: inputFiles.split(' ').filter(w => w !== "").length,

Choose a reason for hiding this comment

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

It means we split only according to space, but will ignore for example newline character or other whitespace characters. Could you fix it please?

// .length;
// console.log(countOfWordsContainingEs);

function countHelper(inputFiles) {

Choose a reason for hiding this comment

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

countHelper is not very clear name, could you rename so naming reflects the purpose of the function?

@SlideGauge SlideGauge 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. Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Feb 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed Volunteer to add when completing a review with trainee action still to take. 📅 Sprint 4 Assigned during Sprint 4 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments