fix(AppData): Fix issue with overwrite object handling in AppData class

This commit is contained in:
Philipp Kunz 2024-11-05 21:29:26 +01:00
parent eff77f8976
commit 1e6f636608
3 changed files with 11 additions and 4 deletions

View File

@ -1,5 +1,10 @@
# Changelog # Changelog
## 2024-11-05 - 5.1.1 - fix(AppData)
Fix issue with overwrite object handling in AppData class
- Corrected logic to handle cases when overwriteObject is undefined.
## 2024-11-05 - 5.1.0 - feat(appdata) ## 2024-11-05 - 5.1.0 - feat(appdata)
Add support for overwriting keys using the overwriteObject option in AppData Add support for overwriting keys using the overwriteObject option in AppData

View File

@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@push.rocks/npmextra', name: '@push.rocks/npmextra',
version: '5.1.0', version: '5.1.1',
description: 'A utility to enhance npm with additional configuration, tool management capabilities, and a key-value store for project setups.' description: 'A utility to enhance npm with additional configuration, tool management capabilities, and a key-value store for project setups.'
} }

View File

@ -177,11 +177,13 @@ export class AppData<T = any> {
await processEnvMapping(key as keyof T, this.options.envMapping[key]); await processEnvMapping(key as keyof T, this.options.envMapping[key]);
} }
if (this.options.overwriteObject) {
for (const key in Object.keys(this.options.overwriteObject)) { for (const key in Object.keys(this.options.overwriteObject)) {
console.log(`-> heads up: overwriting key ${key} from options.overwriteObject`); console.log(`-> heads up: overwriting key ${key} from options.overwriteObject`);
await this.kvStore.writeKey(key as keyof T, this.options.overwriteObject[key]); await this.kvStore.writeKey(key as keyof T, this.options.overwriteObject[key]);
} }
} }
}
this.readyDeferred.resolve(); this.readyDeferred.resolve();
} }