Skip to content

Commit

Permalink
Make it so verifySeedPacket takes a location to make better warnings.
Browse files Browse the repository at this point in the history
Part of #39.
  • Loading branch information
jkomoros committed Jul 8, 2023
1 parent 7e57a16 commit 0e2cd11
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/garden.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export class Garden {
seedPacket.parse(packet);
const expandedPacket = expandSeedPacket(packet);
//This will throw if there are errors in the packet.
const warnings = verifySeedPacket(expandedPacket);
const warnings = verifySeedPacket(location, expandedPacket);
if (!this._location) this._location = location;
for (const [id, seed] of Object.entries(expandedPacket.seeds)) {
const ref : AbsoluteSeedReference = {
Expand Down
4 changes: 2 additions & 2 deletions src/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,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 => {
export const verifySeedPacket = (location: SeedPacketAbsoluteLocation, packet : ExpandedSeedPacket) : Error[] | null => {
const warnings : Error[] = [];
//First sanity check we typecheck, throwing if not.
seedPacket.parse(packet);
Expand All @@ -240,7 +240,7 @@ 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}`);
}
}
if (!packet.environment || !packet.environment.namespace) warnings.push(new Error('namespace is not set. Setting a namespace is recommended'));
if (!packet.environment || !packet.environment.namespace) warnings.push(new Error(`namespace is not set in ${location}. Setting a namespace is recommended`));
return warnings.length ? warnings : null;
};

Expand Down

0 comments on commit 0e2cd11

Please sign in to comment.