Skip to content

Commit

Permalink
feat: support context file location in repository
Browse files Browse the repository at this point in the history
  • Loading branch information
aeworxet committed Jul 4, 2023
1 parent e160a2f commit 8479bbf
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/models/Context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,12 @@ export async function addContext(contextName: string, pathToFile: string) {
export async function editContext(contextName: string, pathToFile: string) {
let fileContent: IContextFile;

try {
fileContent = await loadContextFile();
} catch (e) {
throw e;
}
// The expression is not wrapped in a `try...catch` block and is allowed to
// throw automatically because it is assumed that `loadContextFile()` works
// with a 100%-existing valid file in this case, thus if it threw anyway -
// some REAL error happened and user should know about it.
fileContent = await loadContextFile();

fileContent.store[String(contextName)] = pathToFile;
await saveContextFile(fileContent);
}
Expand Down

0 comments on commit 8479bbf

Please sign in to comment.