microsoft/typespec
Publicmirrored from https://github.com/microsoft/typespecAvailable
packages/migrate/src/utils.ts
15lines · modecode
| 1 | import { globby } from "globby"; |
| 2 | import { join } from "path"; |
| 3 | |
| 4 | export async function findTypeSpecFiles(root: string, ignore: string[] = []) { |
| 5 | return findFiles([normalizePath(join(root, "**/*.tsp"))], ignore); |
| 6 | } |
| 7 | |
| 8 | export async function findFiles(include: string[], ignore: string[] = []): Promise<string[]> { |
| 9 | const patterns = [...include, "!**/node_modules", ...ignore.map((x) => `!${x}`)]; |
| 10 | return globby(patterns); |
| 11 | } |
| 12 | |
| 13 | export function normalizePath(path: string): string { |
| 14 | return path.replace(/\\/g, "/"); |
| 15 | } |
| 16 | |