* * Set default configurations for a node.js module. * * * * This allows module developers to attach their configurations onto the * default configuration object so they can be configured by the consumers * of the module. * * * Using the function wi
(moduleName, defaultProperties)
| 193 | * @see Load.scan() for loading more robust defaults |
| 194 | */ |
| 195 | setModuleDefaults(moduleName, defaultProperties) { |
| 196 | // Copy the properties into a new object |
| 197 | const path = moduleName.split('.'); |
| 198 | const load = this.#config[LOAD_SYMBOL]; |
| 199 | const moduleConfig = load.setModuleDefaults(moduleName, defaultProperties); |
| 200 | let existing = Util.getPath(this.#config, path); |
| 201 | |
| 202 | if (existing === undefined) { |
| 203 | Util.setPath(this.#config, path, Util.cloneDeep(moduleConfig)); |
| 204 | } else { |
| 205 | Util.extendDeep(existing, moduleConfig); |
| 206 | } |
| 207 | |
| 208 | // Attach handlers & watchers onto the module config object |
| 209 | return this.attachProtoDeep(Util.getPath(this.#config, path)); |
| 210 | } |
| 211 | |
| 212 | /** |
| 213 | * Set default configurations for a node.js module. |
no test coverage detected