Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Move overrides handling to config package and unify logging
  • Loading branch information
maff committed Jan 23, 2025
commit 41367234fc9b937bbedfcf1d907fd68d187d92e1
3 changes: 1 addition & 2 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { merge } from "merge-anything";
import YAML from "yaml";

import { logger } from "../logging";
import { applyConfigOverrides } from "../util/config";
import defaultConfigContents from "./git-that-semver.default.yaml" with { type: "text" };
import { applyConfigOverrides } from "./overrides";
import { Config } from "./types";

const configLogger = logger.childLogger("config");
Expand Down Expand Up @@ -54,7 +54,6 @@ export const resolveConfig = async (
if (configOverrides.length > 0) {
configLogger.trace("Config overrides", configOverrides);
mergedConfig = applyConfigOverrides(mergedConfig, configOverrides);
configLogger.trace("Config after applying overrides", mergedConfig);
}

configLogger.trace("Merged config before strategy merge", mergedConfig);
Expand Down
8 changes: 2 additions & 6 deletions src/util/config.ts → src/config/overrides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { set } from "lodash-es";

import { logger } from "../logging";

const utilLogger = logger.childLogger("util/config");
const configLogger = logger.childLogger("config");

function parseConfigOverride(override: string): { path: string; value: any } {
if (!/^[^=]+=[^=]*$/.test(override)) {
Expand Down Expand Up @@ -51,15 +51,11 @@ export function applyConfigOverrides(
): Record<string, any> {
const result = { ...config };

utilLogger.trace("Overrides", overrides);

for (const override of overrides) {
const { path, value } = parseConfigOverride(override);
utilLogger.trace("Applying config override", { path, value });
configLogger.trace("Applying config override", { path, value });
set(result, path, value);
}

utilLogger.trace("Resulting config", result);

return result;
}