| 267 | } |
| 268 | |
| 269 | extendConfiguration(configurationPathKeys, value) { |
| 270 | configurationPathKeys = ensureArray(configurationPathKeys, { |
| 271 | ensureItem: ensureString, |
| 272 | }) |
| 273 | if (configurationPathKeys.length < 1) { |
| 274 | throw new Error( |
| 275 | 'Cannot extend configuration: ConfigurationPathKeys needs to contain at least one element.', |
| 276 | ) |
| 277 | } |
| 278 | |
| 279 | if (!this.isConfigurationExtendable) { |
| 280 | throw new Error( |
| 281 | 'Cannot extend configuration: It can only be extended during initialization phase.', |
| 282 | ) |
| 283 | } |
| 284 | try { |
| 285 | value = JSON.parse(JSON.stringify(value)) |
| 286 | } catch (error) { |
| 287 | throw new Error( |
| 288 | `Cannot extend configuration: Received non JSON value: ${value}`, |
| 289 | ) |
| 290 | } |
| 291 | |
| 292 | _.set(this.configurationInput, configurationPathKeys, value) |
| 293 | if (!_.isObject(value)) { |
| 294 | const lastKey = configurationPathKeys.pop() |
| 295 | value = { [lastKey]: value } |
| 296 | } |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | export default Serverless |