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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add moveSync and its tests #381

Merged
merged 3 commits into from Mar 8, 2017
Merged

Add moveSync and its tests #381

merged 3 commits into from Mar 8, 2017

Conversation

manidlou
Copy link
Collaborator

@manidlou manidlou commented Mar 7, 2017

This should resolves #309.

Manually tested on Ubuntu 16.04 and Windows 10 on virtualbox moved across drives succesfully, cases such as moveSync('G:\\src', 'E:\\nested\\dest').

Like always, please feel free to point out any issues that you can think of 馃槂.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.7%) to 80.177% when pulling c6f795d on moveSync-support into e06440b on master.

Copy link
Collaborator

@RyanZim RyanZim left a comment

Choose a reason for hiding this comment

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

Couple of things to fix, etc.

try {
fse.moveSync(src, dest)
} catch (err) {
assert.ifError(err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

All these try..catch blocks are unnecessary; if moveSync fails, it will automatically fail the test with the error message. Adding a try..catch with an assert.ifError is just redundant.

done()
})
})
*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove this test.

const contents = fs.readFileSync(dest, 'utf8')
const expected = /^sonic the hedgehog\r?\n$/
assert.ok(contents.match(expected), `${contents} match ${expected}`)
tearDownMockFs('EXDEV')
Copy link
Collaborator

Choose a reason for hiding this comment

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

No need to pass a parameter here, tearDownMockFs doesn't use it. Correct other places where this is done.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Very true 馃槃

})
})

describe.skip('> when trying to a move a folder into itself', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why the .skip?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because prevent copying into itself is not implemented yet for copySync. But as I am thinking now, that would work only for the cases if we move across devices. But, when src and dest are on the same device, we still should be able to prevent moving into itself. Is that right?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, just wanted to make sure the .skip wasn't included by mistake.


// tested on Linux ubuntu 3.13.0-32-generic #57-Ubuntu SMP i686 i686 GNU/Linux
// this won't trigger a bug on Mac OS X Yosimite with a USB drive (/Volumes)
// see issue #108
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this comment apply to moveSync?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

// most of this code was written by Andrew Kelley
// licensed under the BSD license: see
// https://github.com/andrewrk/node-mv/blob/master/package.json
// This is the sync version that somehow follows the same pattern.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd say just remove this comment; by now, this is going to barely resemble the original code.

options = options || {}
const overwrite = options.overwrite || options.clobber || false

if (path.resolve(src) === path.resolve(dest)) return
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When src and dest are the same, currently it just return. Which one is better, return or throw an error?

@coveralls
Copy link

Coverage Status

Coverage increased (+1.2%) to 80.704% when pulling 08d7d3a on moveSync-support into 9bef553 on master.

@manidlou
Copy link
Collaborator Author

manidlou commented Mar 8, 2017

Added prevent moving into itself and its tests for moveSync(). Please let me know if there is any issues 馃槃

@coveralls
Copy link

Coverage Status

Coverage increased (+1.2%) to 80.704% when pulling 535fe8d on moveSync-support into 9bef553 on master.

@RyanZim
Copy link
Collaborator

RyanZim commented Mar 8, 2017

@manidlou Do you want this or #374 merged first? (Will cause merge conflicts either way.)


@jprichardson Would like you to look over this before merge.

@jprichardson jprichardson merged commit 1697574 into master Mar 8, 2017
@jprichardson
Copy link
Owner

Thanks @manidlou!

@manidlou
Copy link
Collaborator Author

manidlou commented Mar 8, 2017

@manidlou Do you want this or #374 merged first? (Will cause merge conflicts either way.)

Sorry for late reply as I see this already merged.

Thanks @manidlou!

You're very welcome! 馃槃

@manidlou manidlou deleted the moveSync-support branch March 8, 2017 18:43
@manidlou
Copy link
Collaborator Author

manidlou commented Mar 8, 2017

I will add moveSync docs as well.

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.

moveSync support
4 participants