| 233 | } |
| 234 | |
| 235 | export async function getCliProvidedSchemaFile( |
| 236 | schemaPathFromArgs: string, |
| 237 | cwd: string = process.cwd(), |
| 238 | argumentName: string = '--schema', |
| 239 | ): Promise<GetSchemaResult> { |
| 240 | const absPath = path.resolve(cwd, schemaPathFromArgs) |
| 241 | const customSchemaResult = await readSchemaFromFileOrDirectory(absPath) |
| 242 | if (!customSchemaResult.ok) { |
| 243 | const relPath = path.relative(cwd, absPath) |
| 244 | throw new Error( |
| 245 | `Could not load \`${argumentName}\` from provided path \`${relPath}\`: ${renderLookupError( |
| 246 | customSchemaResult.error, |
| 247 | )}`, |
| 248 | ) |
| 249 | } |
| 250 | |
| 251 | return customSchemaResult.schema |
| 252 | } |
| 253 | |
| 254 | export async function getConfigProvidedSchemaFile(schemaPathFromConfig: string): Promise<GetSchemaResult> { |
| 255 | const schemaResult = await readSchemaFromFileOrDirectory(schemaPathFromConfig) |