feat: Add the effects to the migrations

This commit is contained in:
BluJ
2022-07-28 09:31:12 -06:00
parent ec2845b0e0
commit 21d93c803f
2 changed files with 4 additions and 3 deletions

View File

@@ -11,7 +11,7 @@ const matchConfig = dictionary([string, any]);
* Call with the configuration to get a standard getConfig for the expected exports * Call with the configuration to get a standard getConfig for the expected exports
* Assumption: start9/config.yaml is where the config will be stored * Assumption: start9/config.yaml is where the config will be stored
* Throws: Error if there is no file * Throws: Error if there is no file
* Throws: Error if the config.yaml isn't yaml nor config shape * Throws: Error if the config.yaml isn't yaml nor config shape
* @param spec * @param spec
* @returns * @returns
*/ */
@@ -28,6 +28,7 @@ export const getConfig = (spec: ConfigSpec): ExpectedExports.getConfig =>
effects.info(`Got error ${e} while trying to read the config`); effects.info(`Got error ${e} while trying to read the config`);
return undefined; return undefined;
}); });
return { return {
result: { result: {
config, config,

View File

@@ -20,7 +20,7 @@ export function updateConfig<
version extends string, version extends string,
type extends "up" | "down", type extends "up" | "down",
>( >(
fn: (config: T.Config) => T.Config, fn: (config: T.Config, effects: T.Effects) => T.Config,
configured: boolean, configured: boolean,
noRepeat?: NoRepeat<version, type>, noRepeat?: NoRepeat<version, type>,
noFail = false, noFail = false,
@@ -30,7 +30,7 @@ export function updateConfig<
let config = util.unwrapResultType(await getConfig({})(effects)).config; let config = util.unwrapResultType(await getConfig({})(effects)).config;
if (config) { if (config) {
try { try {
config = fn(config); config = fn(config, effects);
} catch (e) { } catch (e) {
if (!noFail) { if (!noFail) {
throw e; throw e;