MCPcopy
hub / github.com/serverless/serverless / extendConfiguration

Method extendConfiguration

packages/serverless/lib/serverless.js:269–297  ·  view source on GitHub ↗
(configurationPathKeys, value)

Source from the content-addressed store, hash-verified

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
300export default Serverless

Callers 1

constructorMethod · 0.80

Calls 1

setMethod · 0.80

Tested by

no test coverage detected