mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-04-04 22:39:47 +00:00
chore: Update the getCOnfig to use the config builder.
This commit is contained in:
@@ -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),
|
||||||
];
|
];
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user