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