fix relative path resolution in router and link crawling
This commit is contained in:
		
							
								
								
									
										22
									
								
								quartz/util/glob.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								quartz/util/glob.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,22 @@
 | 
			
		||||
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[]
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user