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

[BREAKING] move*(): check paths before moving #623

Merged
merged 3 commits into from Sep 7, 2018
Merged

Conversation

manidlou
Copy link
Collaborator

@manidlou manidlou commented Sep 2, 2018

fix #614 and #608.

Added the same paths checking that we use in copy*() to move*(). This will avoid unexpected behavior and improve reliability of the function!

@manidlou manidlou self-assigned this Sep 2, 2018
@manidlou manidlou added this to the 8.0.0 milestone Sep 2, 2018
@manidlou
Copy link
Collaborator Author

manidlou commented Sep 2, 2018

Just realized I forgot to add the case-insensitive paths test! I add it in a bit.

@coveralls
Copy link

coveralls commented Sep 2, 2018

Coverage Status

Coverage increased (+0.2%) to 86.422% when pulling 818c067 on move-check-paths into e0093f5 on v8-dev.

@manidlou
Copy link
Collaborator Author

manidlou commented Sep 2, 2018

Ready for review! @jprichardson @RyanZim @JPeer264

Copy link
Collaborator

@JPeer264 JPeer264 left a comment

Choose a reason for hiding this comment

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

Clean implementation 👍

@@ -32,9 +33,27 @@ describe('+ move() - prevent moving into itself', () => {
fs.outputFileSync(path.join(src, FILES[1]), dat1)
fs.outputFileSync(path.join(src, FILES[2]), dat2)
fs.outputFileSync(path.join(src, FILES[3]), dat3)
done()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this needed? Just sync code is executed and an async done() is not really needed right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You are right @JPeer264 that's not needed!

const dest = path.join(src, 'dest')
return testError(src, dest, done)
})
it(`should move the directory successfully when dest is 'src_dest'`, done => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't know if it's cleaner this way (at least new paths can be added with less overhead):

[
  'dest',
  'dest/src',
  'src_dest/src',
  ...
].forEach(pathName => {
  it(`should move directory successfully when dest is ${pathName}`, done => {
	const dest = path.join(TEST_DIR, pathName)
    return testSuccessDir(src, dest, done)
  })
})

Copy link
Collaborator Author

@manidlou manidlou Sep 3, 2018

Choose a reason for hiding this comment

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

@JPeer264 you are right that's another way of doing it, however IMHO it is not a top priority now and we can always refactor tests in the future. (copy() also has those tests)

@manidlou
Copy link
Collaborator Author

manidlou commented Sep 6, 2018

@RyanZim ping?!

@RyanZim
Copy link
Collaborator

RyanZim commented Sep 6, 2018

@manidlou If you wrote it, and @JPeer264 & @jprichardson both approve it, I'm good with it; my review isn't needed. Just go ahead and merge, I don't have the bandwidth to properly review it ATM.

@manidlou manidlou merged commit 2c2cfa8 into v8-dev Sep 7, 2018
@manidlou manidlou deleted the move-check-paths branch September 7, 2018 04:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants