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 dest parameter to filter option in copy and copySync #366

Merged
merged 3 commits into from Feb 23, 2017

Conversation

manidlou
Copy link
Collaborator

This resolves #351.

I added dest as an additional parameter to filter option in both copy and copySync.

@coveralls
Copy link

coveralls commented Feb 22, 2017

Coverage Status

Coverage remained the same at 85.434% when pulling 8923097 on add-dest-param-filter-copy into 5ff2fc8 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.

Good start; thanks for all the tests!

A couple of unneeded changes; see the review comments.

@@ -121,29 +147,61 @@ describe('+ copySync()', () => {

assert(!fs.existsSync(path.join(dest, IGNORE)), 'directory was not ignored')
assert(!fs.existsSync(path.join(dest, IGNORE, 'file')), 'file was not ignored')
done()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Revert this change. Using done isn't needed since we are using sync methods here.

@@ -104,9 +129,10 @@ describe('+ copySync()', () => {
assert(!fs.existsSync(path.join(destSub, j.toString())))
}
}
done()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Revert this change. Using done isn't needed since we are using sync methods here.

@@ -35,8 +35,8 @@ function copySync (src, dest, options) {

if (options.filter instanceof RegExp) {
console.warn('Warning: fs-extra: Passing a RegExp filter is deprecated, use a function')
performCopy = options.filter.test(src)
} else if (typeof options.filter === 'function') performCopy = options.filter(src)
performCopy = options.filter.test(src, dest)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This change doesn't do anything; Regex.prototype.test only accepts one param.

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. I missed it. Thanks @RyanZim. Great that you caught this.

lib/copy/ncp.js Outdated
@@ -37,11 +37,11 @@ function ncp (source, dest, options, callback) {
if (filter) {
if (filter instanceof RegExp) {
console.warn('Warning: fs-extra: Passing a RegExp filter is deprecated, use a function')
if (!filter.test(source)) {
if (!filter.test(source, dest)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This change doesn't do anything; Regex.prototype.test only accepts one param.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 85.434% when pulling 75d8ba7 on add-dest-param-filter-copy into 5ff2fc8 on master.

@manidlou
Copy link
Collaborator Author

I fixed them. Please let me know if there is any other issues left.

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.

You removed one extra done that you shouldn't have, other than that, LGTM

fs.mkdirsSync(dest)
try {
fs.copySync(src, dest, filter)
} catch (err) {
assert.ifError(err)
}
assert(!fs.existsSync(path.join(dest, 'subdir')))
done()
Copy link
Collaborator

Choose a reason for hiding this comment

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

You still need done when you're using setTimeout (since that makes the code async).

@coveralls
Copy link

Coverage Status

Coverage remained the same at 85.434% when pulling e261c49 on add-dest-param-filter-copy into 5ff2fc8 on master.

@manidlou
Copy link
Collaborator Author

Should I merge this?

@RyanZim
Copy link
Collaborator

RyanZim commented Feb 22, 2017

@manidlou It's up to you. I was leaving it for @jprichardson, since I'm a bit tired today and could have missed something.


@jprichardson Perhaps we should formalize some collaborator guidelines sometime?

@@ -27,15 +27,15 @@ describe('+ copySync()', () => {
src = path.join(TEST_DIR, 'src')
dest = path.join(TEST_DIR, 'dest')

fs.mkdirsSync(src)
fs.mkdirSync(src)
Copy link
Owner

Choose a reason for hiding this comment

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

Why the conversion here to mkdirSync from mkdirsSync?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I can't speak for @manidlou, but mkdirs technically isn't needed, since we know the parent directory exists.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@jprichardson Perhaps we should formalize some collaborator guidelines sometime? 👍

Why the conversion here to mkdirSync from mkdirsSync?

As @RyanZim mentioned, I thought we wouldn't need to call mkdirs since we know the parent directory exist. So, I guess I should revert to mkdirsSync. Is that right?

And also sorry that I am still not in harmony with you guys. I try my best to be as helpful as possible.

Copy link
Owner

Choose a reason for hiding this comment

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

And also sorry that I am still not in harmony with you guys. I try my best to be as helpful as possible.

@manidlou you're very helpful, thank you!!

@jprichardson Perhaps we should formalize some collaborator guidelines sometime?

I think for now, any modifications (including my own), barring some crazy necessary hot-fix, require at least one other reviewer?

To be clear, it's okay to accept a self-submitted PR, but it must be for a very good reason. We're all professionals here, so I think this loose guideline should be acceptable for now.

Sound good @manidlou @RyanZim?

@jprichardson jprichardson merged commit a37d7bb into master Feb 23, 2017
@jprichardson
Copy link
Owner

Let me know if there is anything else that's needed before I publish 2.1.0.

@manidlou
Copy link
Collaborator Author

Sounds good.

Just a quick question, for issues like #358 that user doesn't experience the issue anymore, is this a correct action to comment something like "closing the issue" and then closing it?

By the way, I close this branch as it is already merged.

@manidlou manidlou deleted the add-dest-param-filter-copy branch February 23, 2017 04:50
@RyanZim
Copy link
Collaborator

RyanZim commented Feb 23, 2017

And also sorry that I am still not in harmony with you guys. I try my best to be as helpful as possible.

You're doing great.

Just a quick question, for issues like #358 that user doesn't experience the issue anymore, is this a correct action to comment something like "closing the issue" and then closing it?

Generally, if the user can't reproduce, then yes, you would comment & close. #358 is a gray area, since it is a problem on other Node versions. I'm personally not sure what to do here. @jprichardson?

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.

Additional param for options.filter() on copy()
4 participants