From a6a766b24e617fe25925020dbcc970fed1b682b1 Mon Sep 17 00:00:00 2001 From: BluJ Date: Thu, 16 Feb 2023 16:28:21 -0700 Subject: [PATCH] chore: Get config takes in the config --- compat/getConfig.ts | 9 +++++---- compat/migrations.ts | 4 +++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/compat/getConfig.ts b/compat/getConfig.ts index 866c82a..3cc8402 100644 --- a/compat/getConfig.ts +++ b/compat/getConfig.ts @@ -18,7 +18,8 @@ const matchConfig = dictionary([string, any]); * @returns */ export const getConfig = - (spec: ConfigSpec): ExpectedExports.getConfig => async (effects) => { + (spec: Config): ExpectedExports.getConfig => + async (effects) => { const config = await effects .readFile({ path: "start9/config.yaml", @@ -34,7 +35,7 @@ export const getConfig = return { result: { config, - spec, + spec: spec.build(), }, }; }; @@ -48,12 +49,12 @@ export const getConfig = * @returns A funnction for getConfig and the matcher for the spec sent in */ export const getConfigAndMatcher = ( - spec: Config | Spec, + spec: Config, ): [ ExpectedExports.getConfig, matches.Parser>, ] => { - const specBuilt: Spec = spec instanceof Config ? spec.build() : spec; + const specBuilt: Spec = spec.build(); return [ async (effects) => { diff --git a/compat/migrations.ts b/compat/migrations.ts index d74b8f9..674309a 100644 --- a/compat/migrations.ts +++ b/compat/migrations.ts @@ -4,6 +4,7 @@ import * as M from "../migrations.ts"; import * as util from "../util.ts"; import { EmVer } from "../emver-lite/mod.ts"; import { ConfigSpec } from "../types/config-types.ts"; +import { Config } from "../config/mod.ts"; export interface NoRepeat { version: version; @@ -31,7 +32,8 @@ export function updateConfig< ): M.MigrationFn { return M.migrationFn(async (effects: T.Effects) => { await noRepeatGuard(effects, noRepeat, async () => { - let config = util.unwrapResultType(await getConfig({})(effects)).config; + let config = + util.unwrapResultType(await getConfig(Config.of({}))(effects)).config; if (config) { try { config = await fn(config, effects);