Skip to content

Commit

Permalink
feat: getFactoryByName
Browse files Browse the repository at this point in the history
  • Loading branch information
Akryum committed Sep 2, 2024
1 parent 98bf4ef commit 1000334
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/core/src/factory/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,13 @@ async function getRepoMetaFactoryStorage(mq: MoquerieInstance) {
metaStorage = await metaStoragePromise
return metaStorage
}

export async function getFactoryByName(mq: MoquerieInstance, name: string) {
const storage = await getFactoryStorage(mq)
const factories = await storage.findAll()
const factory = factories.find(f => f.name === name)
if (!factory) {
throw new Error(`Factory not found: ${name}`)
}
return factory
}

0 comments on commit 1000334

Please sign in to comment.