Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution #245

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Solution #245

wants to merge 1 commit into from

Conversation

ab3MN
Copy link

@ab3MN ab3MN commented Dec 2, 2024

Solution

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.

Your code meets the task requirements and successfully implements the file moving functionality similar to the Linux mv command. Great job! 🎉 While your solution works well, consider adding checks to ensure the source file exists and handling potential errors more gracefully. Additionally, verifying that both source and dest are provided as command-line arguments can help prevent runtime issues. Keep up the good work and continue refining your skills! 😊

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


(() => {
try {
const [source, dest] = process.argv.slice(2);

Choose a reason for hiding this comment

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

Consider adding a check to ensure that both source and dest are provided as command-line arguments. If they are not, you could log an error message and exit the process early to prevent runtime errors.

finalPath = path.resolve(dest, path.basename(source));
}

fs.renameSync(source, finalPath);

Choose a reason for hiding this comment

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

Using fs.renameSync can throw an error if the source file does not exist or if there are permission issues. You might want to add checks to ensure the source file exists before attempting to rename it, or handle specific error types in the catch block.

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