make path and globbing more platform invariant
This commit is contained in:
parent
264ea3d544
commit
d7842e0ce7
7 changed files with 45 additions and 54 deletions
18
quartz/glob.ts
Normal file
18
quartz/glob.ts
Normal 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[]
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue