1 |
|
2 |
|
3 | import type {FilePath} from '@parcel/types';
|
4 |
|
5 | import _isGlob from 'is-glob';
|
6 | import fastGlob, {type FastGlobOptions} from 'fast-glob';
|
7 |
|
8 | function normalisePath(p: string): string {
|
9 | return p.replace(/\\/g, '/');
|
10 | }
|
11 |
|
12 | export function isGlob(p: FilePath) {
|
13 | return _isGlob(normalisePath(p));
|
14 | }
|
15 |
|
16 | export function globSync(
|
17 | p: FilePath,
|
18 | options: FastGlobOptions<FilePath>
|
19 | ): Array<FilePath> {
|
20 | return fastGlob.sync(normalisePath(p), options);
|
21 | }
|
22 |
|
23 | export function glob(
|
24 | p: FilePath,
|
25 | options: FastGlobOptions<FilePath>
|
26 | ): Promise<Array<FilePath>> {
|
27 | return fastGlob(normalisePath(p), options);
|
28 | }
|