UNPKG

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