Skip to content

add solution#514

Open
Eksonurit wants to merge 2 commits into
mate-academy:masterfrom
Eksonurit:develop
Open

add solution#514
Eksonurit wants to merge 2 commits into
mate-academy:masterfrom
Eksonurit:develop

Conversation

@Eksonurit

Copy link
Copy Markdown

No description provided.

@mateacademy-ai-mentor mateacademy-ai-mentor 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.

Review Summary

I am requesting changes because there are still functional issues that will break expected behavior in common scenarios. The main blocker is that when zero or one CLI argument is provided (around the process.argv handling in src/app.js), you log an error but still call copy(source, destination) with undefined values; this can cause extra, unintended errors instead of cleanly exiting once invalid arguments are detected. You should add an early return or process.exit(1) immediately after logging the argument error so the program stops before calling copy.

A second important issue is error output noise when handling directories: after detecting EISDIR, you log a helpful message but then also print the raw error object, which can make the CLI output differ from what tests expect; instead, log only a single clear, user-facing message for this case. Also, your message about arguments currently says something like “Only one argument is provided,” which is misleading when no arguments are given; replace this with a more accurate message indicating that both source and destination paths are required. On the positive side, your core copying logic and same-path guard look good and are close to the requirements. Once you fix the argument control flow and simplify the directory error output, your solution should be in great shape.


✨ 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 thread src/app.js
Comment on lines +12 to +14
if (!source || !destination) {
console.error('Only one argument is provided');
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

After logging the error about invalid arguments, the script still proceeds and later calls copy with possibly undefined paths; add an early return or process.exit to stop execution once you detect missing arguments.

Comment thread src/app.js Outdated
if (err.code === 'EISDIR') {
console.error('You try to use a directory');
}
console.error(err);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You always log the raw error object after handling EISDIR; this might produce extra output beyond the specific message, which can conflict with a "plain" CLI and test expectations. Consider limiting output to a clear, user-friendly error message.

Comment thread src/app.js
}

if (!source || !destination) {
console.error('Only one argument is provided');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The argument error message implies exactly one argument is provided, but this branch also runs when zero arguments are given; consider using a more accurate message for missing source or destination.

@mateacademy-ai-mentor mateacademy-ai-mentor 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.

Review Summary

Your solution is approved because all core functional requirements are met: the app correctly copies files, no-ops when source and destination are the same, exits early when arguments are invalid, and handles directory errors with a clear EISDIR message instead of dumping the raw error. The only remaining issues are around user-facing error message clarity, which are important but not critical blockers for functionality.

To improve, please adjust the messages in src/app.js where you handle invalid argument counts: when both source and destination are missing (e.g., around the branch handling process.argv.length <= 2), prefer something like “Both source and destination paths are required.” instead of “Zero argument is provided” so users immediately know what to supply. Similarly, when exactly one argument is given (the branch around process.argv.length === 3), use a message such as “Please provide both source and destination file paths.” instead of “Only one argument is provided”, which is less descriptive and not very user-focused. These changes will better align your messages with the requirement to clearly state that two paths are needed and will make your CLI more intuitive.

Overall, your main logic, control flow, and error handling are solid; refining these messages will make the user experience more polished and professional.


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

Footnotes

  1. Rate AI review example

Comment thread src/app.js
}

if (!source && !destination) {
console.error('Zero argument is provided');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

For the case when both source and destination are missing, the message "Zero argument is provided" is not very clear or user-focused and doesn't reflect that two arguments (source and destination) are required. Consider changing this to something like “Both source and destination paths are required” so users immediately understand what they must provide.

Comment thread src/app.js
}

if (!source || !destination) {
console.error('Only one argument is provided');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Similarly, this message "Only one argument is provided" doesn’t explain that the program requires two paths (source and destination). Update it to a clearer instruction indicating that both paths must be provided, so the behavior matches the requirement and tests that expect such wording.

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