make path and globbing more platform invariant

This commit is contained in:
Jacky Zhao
2023-08-02 22:10:13 -07:00
parent 264ea3d544
commit d7842e0ce7
7 changed files with 45 additions and 54 deletions

18
quartz/glob.ts Normal file
View File

@ -0,0 +1,18 @@
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[]
}