2023-08-03 08:11:46 +03:00
|
|
|
import path from "path"
|
|
|
|
import { FilePath } from "./path"
|
|
|
|
import { globby } from "globby"
|
2023-08-03 08:10:13 +03:00
|
|
|
|
|
|
|
export function toPosixPath(fp: string): string {
|
|
|
|
return fp.split(path.sep).join("/")
|
|
|
|
}
|
|
|
|
|
2023-08-03 08:11:46 +03:00
|
|
|
export async function glob(
|
|
|
|
pattern: string,
|
|
|
|
cwd: string,
|
|
|
|
ignorePatterns: string[],
|
|
|
|
): Promise<FilePath[]> {
|
2023-08-03 08:10:13 +03:00
|
|
|
const fps = (
|
|
|
|
await globby(pattern, {
|
|
|
|
cwd,
|
|
|
|
ignore: ignorePatterns,
|
|
|
|
gitignore: true,
|
|
|
|
})
|
|
|
|
).map(toPosixPath)
|
|
|
|
return fps as FilePath[]
|
|
|
|
}
|