refactor(storage-fs): yield one migration entry at a time

This commit is contained in:
Joakim Carlstein 2023-11-24 15:47:47 +01:00
parent d8a6a2428a
commit 59a013b0d8

View file

@ -113,12 +113,14 @@ export default function storageFs({ filename }: StorageFsOptions): EmigrateStora
async *getHistory() { async *getHistory() {
const history = await read(); const history = await read();
yield* Object.entries(history).map(([name, { status, date, error }]) => ({ for (const [name, { status, date, error }] of Object.entries(history)) {
name, yield {
status, name,
error, status,
date: new Date(date), date: new Date(date),
})); error: error ? new Error(error.message) : undefined,
};
}
}, },
async onSuccess(migration) { async onSuccess(migration) {
await update(migration.name, 'done'); await update(migration.name, 'done');