Skip to content

Commit f70c3e0

Browse files
committed
feat: remove fast-glob package in favor of Node.js fs.glob
Breaking change: The globs support behavior may different. However, we expect most Japa projects to use standard glob expressions and must work without any issues
1 parent 7d40a71 commit f70c3e0

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
"@poppinss/hooks": "^7.3.0",
6262
"@poppinss/string": "^1.7.1",
6363
"error-stack-parser-es": "^1.0.5",
64-
"fast-glob": "^3.3.3",
6564
"find-cache-directory": "^6.0.0",
6665
"getopts": "^2.3.0",
6766
"supports-color": "^10.2.2"

src/files_manager.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
* file that was distributed with this source code.
88
*/
99

10+
import { join } from 'node:path'
1011
import string from '@poppinss/string'
11-
import fastGlob from 'fast-glob'
12+
import { glob } from 'node:fs/promises'
1213
import { pathToFileURL } from 'node:url'
1314
import type { TestFiles } from './types.js'
1415

@@ -29,13 +30,18 @@ export class FilesManager {
2930
*/
3031
async getFiles(cwd: string, files: TestFiles, excludes: string[]): Promise<URL[]> {
3132
if (Array.isArray(files) || typeof files === 'string') {
32-
const testFiles = await fastGlob(files, {
33-
absolute: true,
34-
onlyFiles: true,
33+
const matchingFiles = glob(files, {
34+
withFileTypes: false,
3535
cwd: cwd,
36-
ignore: excludes,
36+
exclude: excludes,
3737
})
38-
return testFiles.map((file) => pathToFileURL(file))
38+
39+
const testFiles = await Array.fromAsync(matchingFiles)
40+
return testFiles
41+
.sort((current, next) => {
42+
return current.localeCompare(next, undefined, { numeric: true, sensitivity: 'base' })
43+
})
44+
.map((file) => pathToFileURL(join(cwd, file)))
3945
}
4046

4147
return await files()

tests/files_manager.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ test.describe('Files manager | getFiles', () => {
129129

130130
await wrapAssertions(() => {
131131
assert.deepEqual(files, [
132+
new URL('modules/core/main.ts', cwd),
133+
new URL('modules/core/reporters/base.ts', cwd),
134+
new URL('modules/core/types.ts', cwd),
132135
new URL('tests/base_reporter.spec.ts', cwd),
133136
new URL('tests/cli_parser.spec.ts', cwd),
134137
new URL('tests/config_manager.spec.ts', cwd),
@@ -138,9 +141,6 @@ test.describe('Files manager | getFiles', () => {
138141
new URL('tests/helpers.spec.ts', cwd),
139142
new URL('tests/planner.spec.ts', cwd),
140143
new URL('tests/runner.spec.ts', cwd),
141-
new URL('modules/core/main.ts', cwd),
142-
new URL('modules/core/types.ts', cwd),
143-
new URL('modules/core/reporters/base.ts', cwd),
144144
])
145145
})
146146
})

0 commit comments

Comments
 (0)