Skip to content

Commit

Permalink
verifySeedPacket returns a warning if namespace is not set.
Browse files Browse the repository at this point in the history
Part of #39.
  • Loading branch information
jkomoros committed Jul 8, 2023
1 parent d9ed571 commit 8e16e5c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ const collectSeedReferences = (data : ExpandedSeedData) : SeedReference[] => {
//Will throw an error if an error is found. Will return an array of errors
//representing warnings for less significant problems.
export const verifySeedPacket = (packet : ExpandedSeedPacket) : Error[] | null => {
const warnings : Error[] = [];
//First sanity check we typecheck, throwing if not.
seedPacket.parse(packet);
for (const [id, data] of TypedObject.entries(packet.seeds)) {
Expand All @@ -239,7 +240,8 @@ export const verifySeedPacket = (packet : ExpandedSeedPacket) : Error[] | null =
if (!packet.seeds[ref.seed]) throw new Error(`Seed ${id} referenced a non-existent local seed: ${ref.seed}`);
}
}
return null;
if (!packet.environment || !packet.environment.namespace) warnings.push(new Error('namespace is not set. Setting a namespace is recommended'));
return warnings.length ? warnings : null;
};

export class Seed<D extends ExpandedSeedData = ExpandedSeedData> {
Expand Down

0 comments on commit 8e16e5c

Please sign in to comment.