Skip to content

first commit#339

Open
SaXoNG wants to merge 3 commits intomate-academy:masterfrom
SaXoNG:develop
Open

first commit#339
SaXoNG wants to merge 3 commits intomate-academy:masterfrom
SaXoNG:develop

Conversation

@SaXoNG
Copy link

@SaXoNG SaXoNG commented Feb 3, 2026

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Review Summary

Great job implementing the file moving logic! The code correctly handles most scenarios, like renaming files and moving them into existing directories. However, this requires changes because a core requirement is not fully met. The application should throw an error if the destination path ends with a / but the directory does not exist. Currently, a command like node app.js file.txt nonExistentDir/ incorrectly renames the file instead of reporting an error. To fix this, please add a check to see if the original destination argument ends with a /. If it does, and that path is not an existing directory, you should throw an error. Keep up the great work!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

src/app.js Outdated
Comment on lines 32 to 43
if (fs.existsSync(dest) && fs.statSync(dest).isDirectory()) {
fs.renameSync(src, path.join(dest, path.basename(src)));
} else {
const destDir = path.dirname(dest);

if (!fs.existsSync(destDir)) {
console.error('Destination directory does not exist');
process.exit(0);
}

fs.renameSync(src, dest);
}

Choose a reason for hiding this comment

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

This logic block doesn't fully meet the requirements. The task specifies that if a destination path ends with /, it must be treated as a directory, and an error must be thrown if it doesn't exist. This code doesn't check if the original destArg has a trailing slash. As a result, a command like node app.js file.txt nonExistentDir/ incorrectly renames the file instead of throwing the required error.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Review Summary

Great progress on the file mover! You've correctly identified where to add the check for destination paths ending in a /. However, the current implementation has a logic flaw that causes it to report an error even on a successful move, which is a critical issue.

Specifically, in src/app.js, after a successful file move on line 34, the code continues execution and incorrectly prints an error message on line 37. To fix this, you should restructure this logic. The if statement on line 33 correctly checks for the success case (the directory exists), so you can add an else branch to handle the error case. This will ensure an error is shown only when the destination directory doesn't exist.

You're very close to finishing this!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment on lines 33 to 39
if (fs.existsSync(dest) && fs.statSync(dest).isDirectory()) {
fs.renameSync(src, path.join(dest, path.basename(src)));
}

console.error('IT / is in the then it should be folder');

process.exit(0);

Choose a reason for hiding this comment

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

It's great that you've added the check for destination paths ending with a slash, as requested in the previous review. However, this logic block doesn't quite work as intended.

Currently, after a successful file move on line 34, the code continues execution and incorrectly prints an error message on line 37. A successful operation should exit cleanly without any errors.

To fix this, you should restructure this if block. The check on line 33 correctly identifies the success case. You can add an else branch to handle the error case (when the directory does not exist). This will ensure that an error is shown only when it's supposed to, and it will also allow you to provide a more descriptive error message.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Review Summary

Excellent work fixing the core logic from the last review! The program now correctly handles all specified file moving and renaming scenarios.

I am approving this submission as an educational override to help you progress, but there is one small improvement to make. In src/app.js, the error message on line 39 is unclear. It's important for error messages to be descriptive so users know how to fix the problem. A better message would be something like Destination directory does not exist.

Great job on this task, you've built a solid tool!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

process.exit(0);
}

console.error('IT / is in the then it should be folder');

Choose a reason for hiding this comment

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

This error message is not very clear. According to the requirements, an error should be thrown if the destination directory does not exist. A more descriptive message, similar to the one on line 48, would be better. For example: Destination directory does not exist.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants