From 226df32eff99c888599d930ccba03cc3847a9240 Mon Sep 17 00:00:00 2001 From: Alex Komoroske Date: Sat, 22 Jul 2023 14:47:04 -0700 Subject: [PATCH] Make it so profile.localFetch returns a string, not a parsed JSON blob. This will allow it to be used for local fetches. Part of #45. --- src/garden.ts | 3 ++- src/profile.ts | 2 +- tools/profile_filesystem.ts | 5 ++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/garden.ts b/src/garden.ts index 5737649..80c8957 100644 --- a/src/garden.ts +++ b/src/garden.ts @@ -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); } diff --git a/src/profile.ts b/src/profile.ts index 05ae54d..ede87c9 100644 --- a/src/profile.ts +++ b/src/profile.ts @@ -99,7 +99,7 @@ export class Profile{ console.log(message, ...optionalParams); } - async localFetch(_location : string) : Promise { + async localFetch(_location : string) : Promise { throw new Error('localFetch is not supported on this profile type'); } diff --git a/tools/profile_filesystem.ts b/tools/profile_filesystem.ts index 05fbae0..de05a60 100644 --- a/tools/profile_filesystem.ts +++ b/tools/profile_filesystem.ts @@ -44,9 +44,8 @@ export class ProfileFilesystem extends Profile { this._storeFilesystems = {}; } - override async localFetch(location : string) : Promise { - const file = fs.readFileSync(location).toString(); - return JSON.parse(file); + override async localFetch(location : string) : Promise { + return fs.readFileSync(location).toString(); } override async prompt(question: string, defaultValue: LeafValue): Promise {