Skip to content

Conversation

@sheida-shab
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

@sheida-shab sheida-shab added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Tools The name of the module. labels Nov 20, 2025
Copy link

@LonMcGregor LonMcGregor left a comment

Choose a reason for hiding this comment

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

Good work on these tasks, apologies for the lateness in review

You have taken a good approach at manually parsing the arguments. You might consider investigating if there are any libraries or APIs you could use to help you with this. In a more complex shell tool, it might be difficult to manually check arguments this way. It would also make it easier to combine arguments, e.g.allowing wc -w -l instead of only one at a time

lineNumber ++ ;
}
}
}

Choose a reason for hiding this comment

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

The formatting is a bit unclear here, do you know of any tools in the command line or the IDE that could help to improve this?

Copy link
Author

Choose a reason for hiding this comment

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

I’m using VS Code with Prettier enabled, but I’m not sure why the file wasn’t properly formatted when saved. I manually reformatted it afterwards.

const filesNameArray = await glob(fileNamePattern);
filesNameArray.sort();
let lineNumber = 1;
//console.log(filesNameArray);

Choose a reason for hiding this comment

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

Tip: Avoid committing commented old code

Copy link
Author

Choose a reason for hiding this comment

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

I Fixed it.

@@ -0,0 +1,46 @@
import { promises as fs } from "node:fs";
import { glob } from "glob";

Choose a reason for hiding this comment

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

When I run this code I get an error Cannot find package 'glob'. Do you see this also?

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for your comment but I don't see any error !

import { promises as fs } from "node:fs";
async function listDir() {
let finalFileList;
const flag = process.argv[2];

Choose a reason for hiding this comment

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

The readme also asks you to try implementing the -1 option, can you try this?

Copy link
Author

Choose a reason for hiding this comment

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

When I initially implemented the code, the -1 flag behavior was applied automatically by default, so I didn’t explicitly implement it. However, based on your feedback, I have now updated the implementation to handle the -1 flag explicitly.


for(const file of commandLineArray){
const fileContent=await fs.readFile(file , 'utf-8');
const fileBuffer=await fs.readFile(file);

Choose a reason for hiding this comment

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

Do you need to read the file in two times? What impact will this have on performance?

Copy link
Author

Choose a reason for hiding this comment

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

You're right — the file is being read twice unnecessarily, which affects performance. This could be improved by reading the file once and reusing the buffer. I updated the code.

if(commandLineArray.length>1){
switch (flags[0]) {
case "-l":
console.log(`${String(totalLines).padStart(4)} total`);

Choose a reason for hiding this comment

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

There is some duplicated code here, can you reduce that?

Copy link
Author

Choose a reason for hiding this comment

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

I fixed it by implementing a function.

@LonMcGregor LonMcGregor 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 Dec 17, 2025
@sheida-shab sheida-shab added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Dec 18, 2025
@LonMcGregor
Copy link

Good work on this.
I think there was an issue in your "add support for -1 flag" - this seems to have comitted a lot of extra files. There's now 300+ listed in the changeset for this PR. Can you take another look at that?

@LonMcGregor LonMcGregor 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 Dec 22, 2025
@sheida-shab sheida-shab force-pushed the implement-shell-tools branch from 9138dac to 5b9cc2d Compare December 22, 2025 18:07
@sheida-shab
Copy link
Author

sheida-shab commented Dec 24, 2025

Thanks for your feedback.I think I fixed the issue.
Could you please review it again ?

@sheida-shab sheida-shab removed the Reviewed Volunteer to add when completing a review with trainee action still to take. label Dec 24, 2025
@sheida-shab sheida-shab added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Dec 24, 2025
@LonMcGregor
Copy link

This looks good, good work

@LonMcGregor LonMcGregor added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed. Module-Tools The name of the module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants