* if engineOptions.strictPluginMode === true, only accept propertied predefined in EngineOptions. * * @param {IPublicTypeEngineOptions} engineOptions
(engineOptions: IPublicTypeEngineOptions)
| 265 | * @param {IPublicTypeEngineOptions} engineOptions |
| 266 | */ |
| 267 | setEngineOptions(engineOptions: IPublicTypeEngineOptions) { |
| 268 | if (!engineOptions || !isPlainObject(engineOptions)) { |
| 269 | return; |
| 270 | } |
| 271 | const strictMode = getStrictModeValue(engineOptions, STRICT_PLUGIN_MODE_DEFAULT) === true; |
| 272 | if (strictMode) { |
| 273 | const isValidKey = (key: string) => { |
| 274 | const result = (VALID_ENGINE_OPTIONS as any)[key]; |
| 275 | return !(result === undefined || result === null); |
| 276 | }; |
| 277 | Object.keys(engineOptions).forEach((key) => { |
| 278 | if (isValidKey(key)) { |
| 279 | this.set(key, (engineOptions as any)[key]); |
| 280 | } else { |
| 281 | logger.warn(`failed to config ${key} to engineConfig, only predefined options can be set under strict mode, predefined options: `, VALID_ENGINE_OPTIONS); |
| 282 | } |
| 283 | }); |
| 284 | } else { |
| 285 | this.setConfig(engineOptions as any); |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | /** |
| 290 | * 获取指定 key 的值,若此时还未赋值,则等待,若已有值,则直接返回值 |
nothing calls this directly
no test coverage detected