chore: Update the getCOnfig to use the config builder.

This commit is contained in:
BluJ
2023-02-14 10:25:16 -07:00
parent c47fc98620
commit 757033d503

View File

@@ -1,3 +1,4 @@
import { Config } from "../config/config.ts";
import { YAML } from "../dependencies.ts"; import { YAML } from "../dependencies.ts";
import { matches } from "../dependencies.ts"; import { matches } from "../dependencies.ts";
import { ExpectedExports } from "../types.ts"; import { ExpectedExports } from "../types.ts";
@@ -48,8 +49,11 @@ export const getConfig =
* @returns A funnction for getConfig and the matcher for the spec sent in * @returns A funnction for getConfig and the matcher for the spec sent in
*/ */
export const getConfigAndMatcher = <Spec extends ConfigSpec>( export const getConfigAndMatcher = <Spec extends ConfigSpec>(
spec: Spec spec: Config<Spec> | Spec
): [ExpectedExports.getConfig, matches.Parser<unknown, TypeFromProps<Spec>>] => [ ): [ExpectedExports.getConfig, matches.Parser<unknown, TypeFromProps<Spec>>] => {
const specBuilt: Spec = spec instanceof Config ? spec.build() : spec;
return [
async (effects) => { async (effects) => {
const config = await effects const config = await effects
.readFile({ .readFile({
@@ -66,9 +70,10 @@ export const getConfigAndMatcher = <Spec extends ConfigSpec>(
return { return {
result: { result: {
config, config,
spec, spec: specBuilt,
}, },
}; };
}, },
typeFromProps(spec), typeFromProps(specBuilt),
]; ];
};