This repository has been archived on 2024-09-06. You can view files and clone it, but cannot push or open issues or pull requests.
quartz-wiki/quartz/util/glob.ts

23 lines
462 B
TypeScript
Raw Normal View History

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