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

Implement expandGlob() #617

Merged
merged 20 commits into from
Oct 2, 2019
Merged

Implement expandGlob() #617

merged 20 commits into from
Oct 2, 2019

Conversation

nayeemrmn
Copy link
Contributor

@nayeemrmn nayeemrmn commented Sep 28, 2019

...properly. Fixes #576.

This had to be done from scratch unless we could utilise globrex somehow but I think it can be done by splitting paths and flat-mapping on each segment, applying globrex on individual segments. I also want to give it an exclude option so excluded directories won't be traversed - callers all want to exclude by path prefix anyway, this is currently done with a hacky g flag.

Regression. The prettier tests will fail until expandGlob() is fixed
since they try to match absolute paths outside of CWD.
Should help later when extracting common functionality to expandGlob(),
like exclusion. Makes findTestModules() an async generator.
Adds an exclude field to ExpandGlopOptions. This should be the final
API.
In other words, support path prefixes when specifying excludes. This
aligns with the file matchers of the test runner and prettier. It's less
redundant since this cannot be achieved efficiently on the client-end.
@nayeemrmn nayeemrmn force-pushed the expand-glob branch 5 times, most recently from 437e930 to 9b1b634 Compare September 29, 2019 22:32
@nayeemrmn nayeemrmn changed the title Implement expandGlob() [WIP] Implement expandGlob() Sep 29, 2019
@nayeemrmn nayeemrmn marked this pull request as ready for review September 29, 2019 22:42
@nayeemrmn
Copy link
Contributor Author

nayeemrmn commented Sep 29, 2019

@ry @bartlomieju Ready for review!

I've checked that expandGlobSync() on any direct path with an absolute root provided uses just one op! This affects the test runner and prettier. File-system walking is more or less minimised.

fs/walk.ts Show resolved Hide resolved
@ry
Copy link
Member

ry commented Sep 30, 2019

@kt3k a review from you would be appreciated if you have the time.

fs/glob.ts Outdated Show resolved Hide resolved
fs/glob.ts Show resolved Hide resolved
fs/glob.ts Outdated Show resolved Hide resolved
fs/glob.ts Show resolved Hide resolved
@ry
Copy link
Member

ry commented Sep 30, 2019

@nayeemrmn In your description, it says "DON'T MERGE". Please update if it is no longer applicable.

fs/glob.ts Show resolved Hide resolved
@nayeemrmn
Copy link
Contributor Author

@ry Fixed! Ready again.

@kt3k
Copy link
Member

kt3k commented Oct 2, 2019

//fs/README has glob entry. I think we need to update that to globToRegExp as well.

fs/glob.ts Outdated Show resolved Hide resolved
fs/walk.ts Outdated Show resolved Hide resolved
fs/walk_test.ts Show resolved Hide resolved
Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

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

LGTM - nice PR @nayeemrmn!

(And thanks for the careful review @kt3k )

@ry
Copy link
Member

ry commented Oct 2, 2019

@nayeemrmn Can you draft a commit message so I can squash this all up?

fs/glob.ts:
- Improve prototypes for expandGlob() and expandGlobSync() from denoland#604.
- Rename glob() to globToRegExp().
- Add normalizeGlob() and joinGlobs().
- Extract GlobToRegExpOptions from GlobOptions, remove the strict
  and filepath options.

fs/globrex.ts:
- Add GlobrexOptions.

fs/path/constants.ts:
- Add SEP_PATTERN.

fs/walk.ts:
- Add WalkOptions::includeFiles
- Default WalkOptions::includeDirs to true.
- Don't traverse directories matching a skip pattern.
- Remove walkSync()'s default root value.

prettier:
- Refactor to use expandGlob().

testing:
- Make findTestModules() an async generator.
@nayeemrmn
Copy link
Contributor Author

@ry Added an empty commit with the message.

@ry ry merged commit 8c90bd9 into denoland:master Oct 2, 2019
@nayeemrmn nayeemrmn deleted the expand-glob branch October 2, 2019 18:04
ry pushed a commit to ry/deno that referenced this pull request Oct 9, 2019
fs/glob.ts:
- Improve prototypes for expandGlob() and expandGlobSync() from denoland/std#604.
- Rename glob() to globToRegExp().
- Add normalizeGlob() and joinGlobs().
- Extract GlobToRegExpOptions from GlobOptions, remove the strict
  and filepath options.

fs/globrex.ts:
- Add GlobrexOptions.

fs/path/constants.ts:
- Add SEP_PATTERN.

fs/walk.ts:
- Add WalkOptions::includeFiles
- Default WalkOptions::includeDirs to true.
- Don't traverse directories matching a skip pattern.
- Remove walkSync()'s default root value.

prettier:
- Refactor to use expandGlob().

testing:
- Make findTestModules() an async generator.
Original: denoland/std@8c90bd9
inverted-capital pushed a commit to dreamcatcher-tech/napps that referenced this pull request Oct 24, 2024
Fixes various minor JSDoc snippet issues.
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.

Test runner file matcher should walk as little as possible
4 participants