mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-30 20:24:47 +00:00
fix: Type to include promise
This commit is contained in:
@@ -19,18 +19,18 @@ export interface NoRepeat<version extends string, type extends "up" | "down"> {
|
|||||||
export function updateConfig<
|
export function updateConfig<
|
||||||
version extends string,
|
version extends string,
|
||||||
type extends "up" | "down",
|
type extends "up" | "down",
|
||||||
>(
|
>(
|
||||||
fn: (config: T.Config, effects: T.Effects) => T.Config,
|
fn: (config: T.Config, effects: T.Effects) => T.Config | Promise<T.Config>,
|
||||||
configured: boolean,
|
configured: boolean,
|
||||||
noRepeat?: NoRepeat<version, type>,
|
noRepeat?: NoRepeat<version, type>,
|
||||||
noFail = false,
|
noFail = false,
|
||||||
): M.MigrationFn<version, type> {
|
): M.MigrationFn<version, type> {
|
||||||
return M.migrationFn(async (effects: T.Effects) => {
|
return M.migrationFn(async (effects: T.Effects) => {
|
||||||
await noRepeatGuard(effects, noRepeat, async () => {
|
await noRepeatGuard(effects, noRepeat, async () => {
|
||||||
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, effects);
|
config = await fn(config, effects);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (!noFail) {
|
if (!noFail) {
|
||||||
throw e;
|
throw e;
|
||||||
@@ -48,10 +48,10 @@ export function updateConfig<
|
|||||||
export async function noRepeatGuard<
|
export async function noRepeatGuard<
|
||||||
version extends string,
|
version extends string,
|
||||||
type extends "up" | "down",
|
type extends "up" | "down",
|
||||||
>(
|
>(
|
||||||
effects: T.Effects,
|
effects: T.Effects,
|
||||||
noRepeat: NoRepeat<version, type> | undefined,
|
noRepeat: NoRepeat<version, type> | undefined,
|
||||||
fn: () => Promise<void>,
|
fn: () => Promise<void>,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
if (!noRepeat) {
|
if (!noRepeat) {
|
||||||
return fn();
|
return fn();
|
||||||
|
|||||||
Reference in New Issue
Block a user