Skip to content

Commit

Permalink
fix: Fix ts-import strategy.
Browse files Browse the repository at this point in the history
  • Loading branch information
darkobits committed Jun 25, 2023
1 parent 2916ee2 commit 435d525
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/lib/configuration/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ export default async function configurationLoader(filePath: string, content: str
errors.push(err);
}


if (errors.length > 0) {
throw new AggregateError(errors, 'All parsing strategies failed.');
}
if (errors.length > 0) throw new AggregateError(
errors,
'All parsing strategies failed.'
);
}
5 changes: 5 additions & 0 deletions src/lib/configuration/strategies/esbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ export async function esbuildStrategy(filePath: string, pkgInfo: PackageInfo) {
const result = await import(tempFilePath);

return result?.default ?? result;
} catch (cause: any) {
throw new Error(
`${log.prefix('esbuildStrategy')} Failed to load configuration file: ${cause}`,
{ cause }
);
} finally {
if (await fs.exists(tempFilePath)) {
await fs.remove(tempFilePath);
Expand Down
7 changes: 5 additions & 2 deletions src/lib/configuration/strategies/ts-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ export async function tsImportStrategy(filePath: string) {
});

return result?.default || result;
} catch (err: any) {
log.error(log.prefix('ts-import'), 'Error removing cache directory:', err);
} catch (cause: any) {
throw new Error(
`${log.prefix('tsImportStrategy')} Failed to load configuration file: ${cause}`,
{ cause }
);
} finally {
if (await fs.exists(cacheDir)) await fs.remove(cacheDir);
}
Expand Down

0 comments on commit 435d525

Please sign in to comment.