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

add solution #247

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

Conversation

Valentyn-Radobenko
Copy link

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.

Great job on implementing the core functionality of moving files! 🎉 Your code meets the task requirements, and you've handled most scenarios well. Just a couple of things to keep in mind: make sure to check if the destination directory exists and create it if necessary, and use fs.rename instead of fs.moveFile to avoid runtime errors. Keep up the good work and happy coding! 😊

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

return;
}

await fs.moveFile(absSrc, absDest);

Choose a reason for hiding this comment

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

The fs.moveFile function does not exist in the fs/promises module. You should use fs.rename for moving files or consider using a third-party library like fs-extra that provides a move function.

return;
}

const destStats = await fs.stat(absDest);

Choose a reason for hiding this comment

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

Before calling fs.stat on absDest, you should check if the destination path exists to avoid errors. Consider using fs.access to verify the existence of the path.

Comment on lines +36 to +37
if (destStats.isDirectory()) {
await fs.rename(absSrc, `${absDest}/${absSrc.split(path.sep).pop()}`);

Choose a reason for hiding this comment

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

When moving a file to a directory, ensure that the directory exists. If it doesn't, you might want to create it using fs.mkdir with the { recursive: true } option.

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