Skip to content

Commit

Permalink
fix: trying to start a plugin, errors for dependencies were not reported
Browse files Browse the repository at this point in the history
  • Loading branch information
rejetto committed Dec 10, 2023
1 parent b59fb98 commit 1e23571
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,8 @@ function watchPlugin(id: string, path: string) {
starting = pendingPromise()
// if dependencies are not ready right now, we give some time. Not super-solid but good enough for now.
const info = await parsePlugin()
if (!await waitFor(async () => _.isEmpty(await getMissingDependencies(info)), { timeout: 5_000 }))
return console.debug("plugin missing dependencies", id)
if (!await waitFor(() => _.isEmpty(getMissingDependencies(info)), { timeout: 5_000 }))
throw Error("plugin missing dependencies: " + _.map(getMissingDependencies(info), x => x.repo).join(', '))
if (getPluginInfo(id))
setError(id, '')
const alreadyRunning = plugins[id]
Expand Down Expand Up @@ -424,7 +424,9 @@ function getError(id: string) {
}

function setError(id: string, error: string) {
getPluginInfo(id).error = error
const info = getPluginInfo(id)
if (!info) return
info.error = error
events.emit('pluginUpdated', { id, error })
}

Expand Down Expand Up @@ -476,7 +478,7 @@ function calculateBadApi(data: AvailablePlugin) {
: undefined
}

export async function getMissingDependencies(plugin: CommonPluginInterface) {
export function getMissingDependencies(plugin: CommonPluginInterface) {
return onlyTruthy((plugin?.depend || []).map((dep: any) => {
const res = findPluginByRepo(dep.repo)
const error = !res ? 'missing'
Expand Down

0 comments on commit 1e23571

Please sign in to comment.