Skip to content
This repository has been archived by the owner on Dec 21, 2024. It is now read-only.

Commit

Permalink
chore: allow non-existent local registry dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanFlurry committed Sep 12, 2024
1 parent 58a2d2f commit 4c5d01d
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions packages/backend/toolchain/project/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ export async function loadRegistry(
}

async function indexRegistryModules(registry: ResolveRegistryOutput): Promise<Record<string, IndexedModuleConfig>> {
// Don't index if modules dir doesn't exist. We do this so we can auto-add a
// local registry in a dev project without a modules folder existing yet.
if (!await exists(registry.path, { isDirectory: true })) {
return {};
}

const modules = new Map<string, IndexedModuleConfig>();
for await (const dirEntry of Deno.readDir(registry.path)) {
if (!dirEntry.isDirectory) {
Expand All @@ -85,7 +91,7 @@ async function indexRegistryModules(registry: ResolveRegistryOutput): Promise<Re
);
modules.set(dirEntry.name, { status, name, description, icon, dependencies, defaultConfig, tags });
} catch {
// ignore this module
// Ignore this module
}
}

Expand Down Expand Up @@ -127,20 +133,16 @@ interface ResolveRegistryOutput {

async function resolveRegistryLocal(
projectRoot: string,
name: string,
_name: string,
config: RegistryConfigLocal,
): Promise<ResolveRegistryOutput> {
const projectConfigPath = resolve(projectRoot, "rivet.json");

const isExternal = config.isExternal ?? false;

// Check that registry exists
// Generate registry path
//
// This path doesn't need to exist. We'll throw an error if we try to load a
// module from this registry.
const path = resolve(projectRoot, config.directory);
if (!await exists(path)) {
throw new UserError(`Could not find directory ${path} for local registry \`${name}\`.`, {
path: projectConfigPath,
});
}

return { path, isExternal };
}
Expand Down

0 comments on commit 4c5d01d

Please sign in to comment.