Skip to content

Commit

Permalink
refactor: ts-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Princesseuh committed Aug 8, 2024
1 parent 6fb3f4f commit fc2b6a9
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/ts-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ export = createLanguageServicePlugin((ts, info) => {
let collectionConfig = undefined;

try {
collectionConfig = {
folder: info.project.getCurrentDirectory(),
config: JSON.parse(
ts.sys.readFile(
info.project.getCurrentDirectory() + '/.astro/collections/collections.json',
) as string,
) as CollectionConfig['config'],
};
const currentDir = info.project.getCurrentDirectory();
const fileContent = ts.sys.readFile(currentDir + '/.astro/collections/collections.json');
if (fileContent) {
collectionConfig = {
folder: currentDir,
config: JSON.parse(fileContent) as CollectionConfig['config'],
};
}
} catch (err) {
// If the file doesn't exist, we don't really care, but if it's something else, we want to know
if (err && (err as any).code !== 'ENOENT') console.error(err);
Expand Down

0 comments on commit fc2b6a9

Please sign in to comment.