(schemaFile: string)
| 132 | } |
| 133 | |
| 134 | async function loadSchemaFile(schemaFile: string): Promise<IPublicTypeProjectSchema> { |
| 135 | if (!schemaFile) { |
| 136 | throw new Error('invalid schema file name'); |
| 137 | } |
| 138 | |
| 139 | const schemaFileContent = await fs.readFile(schemaFile, 'utf8'); |
| 140 | |
| 141 | if (/\.json5/.test(schemaFile)) { |
| 142 | return JSON5.parse(schemaFileContent); |
| 143 | } |
| 144 | |
| 145 | // 默认用 JSONC 的格式解析(兼容 JSON) |
| 146 | return jsonc.parse(schemaFileContent); |
| 147 | } |