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

Suggested fix for #97, review of implications required #107

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nilsvu
Copy link

@nilsvu nilsvu commented Jan 17, 2018

With the prepended slash, minimatch will never actually return an object with negate: true, so it's impossible to ignore files in clean operations. Please review this change and consider implications to the remaining codebase - perhaps even consider refactoring to use the glob processing implementation in vinyl-fs, that also gulp.src uses, if possible?

Fixes #97

@nilsvu nilsvu changed the title Suggested fix for #33, review of implications required Suggested fix for #97, review of implications required Jan 17, 2018
@morris morris added the bug label Jan 27, 2018
@morris
Copy link
Owner

morris commented Jan 27, 2018

This looks like it could break a lot of scripts relying on the current behavior. Could you update this to still prepend the slash but somehow parse the negation beforehand? Ideally with a test? Many thanks!

nilsvu and others added 2 commits January 27, 2018 16:28
With the prepended slash, minimatch will never actually return an object with negate: true, so it's impossible to ignore files in clean operations. Please review this change and consider implications to the remaining codebase - perhaps even consider refactoring to use the glob processing implementation in vinyl-fs, that also gulp.src uses, if possible?
glob = self.join( '!', glob );
}

var mm = new Minimatch( glob, options );
Copy link
Author

Choose a reason for hiding this comment

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

This should properly handle leading negation characters ! while keeping the behaviour of prepending a slash. However, I don't quite see why prepending a slash is necessary or even useful - it may even lead to problems where the user doesn't expect this behaviour.
I'd also suggest moving to the glob parsing of vinyl-fs, as proposed above, but I don't have enough knowledge of the code to implement this.


done = suite.done( done );

suite.vftp.clean( 'test/clean/**', 'test/fixtures' )
suite.vftp.clean( [ 'test/clean/**/*', '!test/clean/dontcleanthis/**/*' ], 'test/fixtures' )
.on( 'error', done )
Copy link
Author

Choose a reason for hiding this comment

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

This practice of calling done on error, as adopted in the other tests as well, appears problematic to me. For example the operation may fail to delete a file, because its containing directory has already been deleted. This throws an error which is handled here by calling done, essentially marking the test as successful and bypassing the checks below. Try adding a check assert.ok(false) below - it will still succeed if an error occurs.


done = suite.done( done );

suite.vftp.clean( 'test/clean/**', 'test/fixtures' )
suite.vftp.clean( [ 'test/clean/**/*', '!test/clean/dontcleanthis/**/*' ], 'test/fixtures' )
Copy link
Author

Choose a reason for hiding this comment

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

This operation doesn't quite work yet, and the problem may lie with the implementation of the clean function. Skimming its implementation, it appears a directory can be deleted even though one or more of its containing files is excluded from the clean operation. I don't have enough insight into the code to fix this quickly, so could use some help here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants