Skip to content

Commit

Permalink
Make it so profile.localFetch returns a string, not a parsed JSON blob.
Browse files Browse the repository at this point in the history
This will allow it to be used for local fetches.

Part of #45.
  • Loading branch information
jkomoros committed Jul 22, 2023
1 parent e663485 commit 226df32
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/garden.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ export class Garden {
if (verbose) {
this.profile.log(`Fetching local seed packet: ${location}`);
}
const data = await this.profile.localFetch(location);
const str = await this.profile.localFetch(location);
const data = JSON.parse(str);
return seedPacket.parse(data);
}

Expand Down
2 changes: 1 addition & 1 deletion src/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class Profile{
console.log(message, ...optionalParams);
}

async localFetch(_location : string) : Promise<unknown> {
async localFetch(_location : string) : Promise<string> {
throw new Error('localFetch is not supported on this profile type');
}

Expand Down
5 changes: 2 additions & 3 deletions tools/profile_filesystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ export class ProfileFilesystem extends Profile {
this._storeFilesystems = {};
}

override async localFetch(location : string) : Promise<unknown> {
const file = fs.readFileSync(location).toString();
return JSON.parse(file);
override async localFetch(location : string) : Promise<string> {
return fs.readFileSync(location).toString();
}

override async prompt(question: string, defaultValue: LeafValue): Promise<string> {
Expand Down

0 comments on commit 226df32

Please sign in to comment.