Skip to content

Conversation

cb1kenobi
Copy link
Contributor

With this fix, paths can now reference files outside the current working directory. So now, the pattern **/*.js will match ../../some/file.js

The only caveat is your pattern has to start with ** to match the resolved absolute paths of relative parent paths. In other words, you must do**/test/**/*.js in order to match ../../test/file.js and not match ../../src/code.js. This is a limitation of minimatch, not gulp-filter, gulp, or this PR.

Fixes #74.

@nfroidure
Copy link
Contributor

Node 0.12 and lower are broken but i think we should drop its support (2 LTS versions behind us). Also, i think we should add a major version since it may break some existing code. Otherwise i think we should merge this since it looks like a lot of people could benefit from it.

We still have the choice to make this behavior optional and only bump a minor version.

index.js Outdated
match = pattern(file);
} else {
var relPath = path.relative(file.cwd, file.path);
if (relPath.indexOf('..') === 0) {
Copy link
Owner

Choose a reason for hiding this comment

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

'..' => '../'

Copy link
Owner

Choose a reason for hiding this comment

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

And needs a short code comment about why it's there.

@sindresorhus
Copy link
Owner

I'll drop Node.js 0.12 support after this PR is merged. Just ignore the failure for now.

@sindresorhus sindresorhus changed the title Added support for relative parent paths. Add support for relative parent paths Jan 10, 2017
@sindresorhus sindresorhus merged commit f148c7b into sindresorhus:master Jan 10, 2017
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.

Matching parent paths

3 participants