Skip to content

Commit

Permalink
close evaluator even if loadFromPath fails
Browse files Browse the repository at this point in the history
  • Loading branch information
jasongwartz committed Mar 2, 2024
1 parent cfafcda commit 7ac0b2a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions codegen/src/internal/TypescriptModule.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,12 @@ contents: String = new Listing {
// LoadFromPath loads the pkl module at the given path and evaluates it into a \(moduleClass.name)
export const loadFromPath = async (path: string): Promise<\(moduleClass.type.render(moduleClass.typescriptModule))> => {
const evaluator = await pklTypescript.newEvaluator(pklTypescript.PreconfiguredOptions);
const result = await load(evaluator, pklTypescript.FileSource(path));
evaluator.close()
return result
try {
const result = await load(evaluator, pklTypescript.FileSource(path));
return result
} finally {
evaluator.close()
}
};
export const load = (evaluator: pklTypescript.Evaluator, source: pklTypescript.ModuleSource): Promise<\(moduleClass.type.render(moduleClass.typescriptModule))> =>
Expand Down

0 comments on commit 7ac0b2a

Please sign in to comment.