Skip to content

Commit 56b1fe9

Browse files
committed
refactor: Make ConfigUpdater handle a null config so the supplied function doesn't have to.
1 parent 6422991 commit 56b1fe9

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ export const DebugLoggingOptionId = 'debugLogging'
2222
* logs, to make it easier to debug the module in case of error. Add a default
2323
* value for that option to older configs.
2424
*/
25-
export function tryUpdateConfigWithDebugLogging(config: RawConfig | null): boolean {
26-
if (config !== null && !(DebugLoggingOptionId in config)) {
25+
export function tryUpdateConfigWithDebugLogging(config: RawConfig): boolean {
26+
if (!(DebugLoggingOptionId in config)) {
2727
config[DebugLoggingOptionId] = false
2828
return true
2929
}

src/upgrades.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ function ActionUpdater(
2020
}
2121
}
2222

23-
function ConfigUpdater(tryUpdate: (config: RawConfig | null) => boolean): CompanionStaticUpgradeScript<RawConfig> {
23+
function ConfigUpdater(tryUpdate: (config: RawConfig) => boolean): CompanionStaticUpgradeScript<RawConfig> {
2424
return (_context: CompanionUpgradeContext<RawConfig>, props: CompanionStaticUpgradeProps<RawConfig>) => {
2525
return {
2626
updatedActions: [],
27-
updatedConfig: tryUpdate(props.config) ? props.config : null,
27+
updatedConfig: props.config !== null && tryUpdate(props.config) ? props.config : null,
2828
updatedFeedbacks: [],
2929
}
3030
}
@@ -35,4 +35,4 @@ export const UpgradeScripts = [
3535
ConfigUpdater(tryUpdateConfigWithDebugLogging),
3636
ActionUpdater(tryUpdateRecallSetPresetActions),
3737
ActionUpdater(tryUpdatePresetAndSpeedEncodingsInActions),
38-
]
38+
] satisfies CompanionStaticUpgradeScript<RawConfig>[]

0 commit comments

Comments
 (0)