|
2 | 2 |
|
3 | 3 | const gracefulFs = require('graceful-fs');
|
4 | 4 | const fs = require('fs');
|
5 |
| -const glob = require('glob'); |
| 5 | +const { globSync } = require('tinyglobby'); |
6 | 6 | const path = require('path');
|
7 | 7 | const Parser = require('./Parser');
|
8 | 8 | const Project = require('./Project');
|
@@ -59,44 +59,39 @@ function resolveCliArgGlob(
|
59 | 59 | path.resolve(fileGlob)
|
60 | 60 | );
|
61 | 61 |
|
62 |
| - // glob@8 (via minimatch@5) had a breaking change where you _have_ to use |
63 |
| - // forwards slash as path separator, regardless of platform, making it |
64 |
| - // unambiguous which characters are separators and which are escapes. This |
65 |
| - // restores the previous behavior, avoiding a breaking change in elm-test. |
| 62 | + // The globs _have_ to use forwards slash as path separator, regardless of |
| 63 | + // platform, making it unambiguous which characters are separators and which |
| 64 | + // are escapes. |
66 | 65 | // Note: As far I can tell, escaping glob syntax has _never_ worked on
|
67 | 66 | // Windows. In Elm, needing to escape glob syntax should be very rare, since
|
68 | 67 | // Elm file paths must match the module name (letters only). So it’s probably
|
69 | 68 | // more worth supporting `some\folder\*Test.elm` rather than escaping.
|
70 |
| - // https://github.com/isaacs/node-glob/issues/468 |
71 |
| - // https://github.com/isaacs/minimatch/commit/9104d8d175bdd8843338103be1401f80774d2a10#diff-f41746899d033115e03bebe4fbde76acf2de4bf261bfb221744808f4c8a286cf |
72 | 69 | const pattern =
|
73 | 70 | process.platform === 'win32'
|
74 | 71 | ? globRelativeToProjectRoot.replace(/\\/g, '/')
|
75 | 72 | : globRelativeToProjectRoot;
|
76 | 73 |
|
77 |
| - return glob |
78 |
| - .sync(pattern, { |
79 |
| - cwd: projectRootDir, |
80 |
| - nocase: true, |
81 |
| - absolute: true, |
82 |
| - ignore: ignoredDirsGlobs, |
83 |
| - // Match directories as well and mark them with a trailing slash. |
84 |
| - nodir: false, |
85 |
| - mark: true, |
86 |
| - }) |
87 |
| - .flatMap((filePath) => |
88 |
| - filePath.endsWith('/') ? findAllElmFilesInDir(filePath) : filePath |
89 |
| - ); |
| 74 | + return globSync(pattern, { |
| 75 | + cwd: projectRootDir, |
| 76 | + caseSensitiveMatch: false, |
| 77 | + absolute: true, |
| 78 | + ignore: ignoredDirsGlobs, |
| 79 | + // Match directories as well |
| 80 | + onlyFiles: false, |
| 81 | + }).flatMap((filePath) => |
| 82 | + // Directories have their path end with `/` |
| 83 | + filePath.endsWith('/') ? findAllElmFilesInDir(filePath) : filePath |
| 84 | + ); |
90 | 85 | }
|
91 | 86 |
|
92 | 87 | // Recursively search for *.elm files.
|
93 | 88 | function findAllElmFilesInDir(dir /*: string */) /*: Array<string> */ {
|
94 |
| - return glob.sync('**/*.elm', { |
| 89 | + return globSync('**/*.elm', { |
95 | 90 | cwd: dir,
|
96 |
| - nocase: true, |
| 91 | + caseSensitiveMatch: false, |
97 | 92 | absolute: true,
|
98 | 93 | ignore: ignoredDirsGlobs,
|
99 |
| - nodir: true, |
| 94 | + onlyFiles: true, |
100 | 95 | });
|
101 | 96 | }
|
102 | 97 |
|
|
0 commit comments