| 55 | ): Promise<SchemaContext | null> |
| 56 | export async function loadSchemaContext(opts?: LoadSchemaContextOptions): Promise<SchemaContext> |
| 57 | export async function loadSchemaContext( |
| 58 | { schemaPath, printLoadMessage, allowNull, schemaPathArgumentName, cwd }: LoadSchemaContextOptions = { |
| 59 | schemaPath: { baseDir: process.cwd() }, |
| 60 | printLoadMessage: true, |
| 61 | allowNull: false, |
| 62 | schemaPathArgumentName: '--schema', |
| 63 | cwd: process.cwd(), |
| 64 | }, |
| 65 | ): Promise<SchemaContext | null> { |
| 66 | let schemaResult: GetSchemaResult | null = null |
| 67 | |
| 68 | if (allowNull) { |
| 69 | schemaResult = await getSchemaWithPathOptional({ schemaPath, cwd, argumentName: schemaPathArgumentName }) |
| 70 | if (!schemaResult) return null |
| 71 | } else { |
| 72 | schemaResult = await getSchemaWithPath({ schemaPath, cwd, argumentName: schemaPathArgumentName }) |
| 73 | } |
| 74 | |
| 75 | return processSchemaResult({ schemaResult, printLoadMessage, cwd }) |
| 76 | } |
| 77 | |
| 78 | export async function processSchemaResult({ |
| 79 | schemaResult, |