-
Notifications
You must be signed in to change notification settings - Fork 81
Replace glob by tinyglobby #647
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
Changes from all commits
9f7de94
119168a
7814ff7
46ca4aa
36cdb47
2f74665
494a435
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
|
|
||
| const gracefulFs = require('graceful-fs'); | ||
| const fs = require('fs'); | ||
| const glob = require('glob'); | ||
| const { globSync } = require('tinyglobby'); | ||
| const path = require('path'); | ||
| const Parser = require('./Parser'); | ||
| const Project = require('./Project'); | ||
|
|
@@ -59,44 +59,39 @@ function resolveCliArgGlob( | |
| path.resolve(fileGlob) | ||
| ); | ||
|
|
||
| // glob@8 (via minimatch@5) had a breaking change where you _have_ to use | ||
| // forwards slash as path separator, regardless of platform, making it | ||
| // unambiguous which characters are separators and which are escapes. This | ||
| // restores the previous behavior, avoiding a breaking change in elm-test. | ||
| // The globs _have_ to use forwards slash as path separator, regardless of | ||
| // platform, making it unambiguous which characters are separators and which | ||
| // are escapes. | ||
| // Note: As far I can tell, escaping glob syntax has _never_ worked on | ||
| // Windows. In Elm, needing to escape glob syntax should be very rare, since | ||
| // Elm file paths must match the module name (letters only). So it’s probably | ||
| // more worth supporting `some\folder\*Test.elm` rather than escaping. | ||
| // https://github.com/isaacs/node-glob/issues/468 | ||
| // https://github.com/isaacs/minimatch/commit/9104d8d175bdd8843338103be1401f80774d2a10#diff-f41746899d033115e03bebe4fbde76acf2de4bf261bfb221744808f4c8a286cf | ||
| const pattern = | ||
| process.platform === 'win32' | ||
| ? globRelativeToProjectRoot.replace(/\\/g, '/') | ||
| : globRelativeToProjectRoot; | ||
|
|
||
| return glob | ||
| .sync(pattern, { | ||
| cwd: projectRootDir, | ||
| nocase: true, | ||
| absolute: true, | ||
| ignore: ignoredDirsGlobs, | ||
| // Match directories as well and mark them with a trailing slash. | ||
| nodir: false, | ||
| mark: true, | ||
| }) | ||
| .flatMap((filePath) => | ||
| filePath.endsWith('/') ? findAllElmFilesInDir(filePath) : filePath | ||
| ); | ||
| return globSync(pattern, { | ||
| cwd: projectRootDir, | ||
| caseSensitiveMatch: false, | ||
| absolute: true, | ||
| ignore: ignoredDirsGlobs, | ||
| // Match directories as well | ||
| onlyFiles: false, | ||
| }).flatMap((filePath) => | ||
| // Directories have their path end with `/` | ||
| filePath.endsWith('/') ? findAllElmFilesInDir(filePath) : filePath | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note to self: Does it end with a slash on Windows? We don’t seem to have test coverage for this condition being true.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added test case: Btw, that test was failing on master – see #648. But it passed when installing glob 8 instead of 10. Another breakage by glob 🙈 |
||
| ); | ||
| } | ||
|
|
||
| // Recursively search for *.elm files. | ||
| function findAllElmFilesInDir(dir /*: string */) /*: Array<string> */ { | ||
| return glob.sync('**/*.elm', { | ||
| return globSync('**/*.elm', { | ||
| cwd: dir, | ||
| nocase: true, | ||
| caseSensitiveMatch: false, | ||
| absolute: true, | ||
| ignore: ignoredDirsGlobs, | ||
| nodir: true, | ||
| onlyFiles: true, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| }); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self: there a big comment above about glob@8 and Windows and backslashes. Try it out on Windows to see how it behaves in tinyglobby, and remove or update the code/comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s needed:
7814ff7(#647)Updated the comment:
46ca4aa(#647)