-
Notifications
You must be signed in to change notification settings - Fork 310
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
base: master
Are you sure you want to change the base?
add solution #247
Conversation
There was a problem hiding this 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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
if (destStats.isDirectory()) { | ||
await fs.rename(absSrc, `${absDest}/${absSrc.split(path.sep).pop()}`); |
There was a problem hiding this comment.
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.
No description provided.