Skip to content

Commit

Permalink
fix(core): fixed windows issue for fetching config files
Browse files Browse the repository at this point in the history
  • Loading branch information
David Boyne authored and David Boyne committed Sep 17, 2024
1 parent c1d8b7c commit bf4795f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions scripts/eventcatalog-config-file-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { readFile, writeFile, rm } from 'node:fs/promises';
import { existsSync } from 'fs';
import path from 'node:path';
import { v4 as uuidV4 } from 'uuid';
import { pathToFileURL } from 'url';

// * Very strange behaviour when importing ESM files from catalogs into core.
// * Very strange behavior when importing ESM files from catalogs into core.
// * Core (node) does not know how to handle ESM files, so we have to try and convert them.
// *
// * This needs sorting out! Sorry if you are reading this, but it unblocked me for now!
Expand Down Expand Up @@ -46,7 +47,9 @@ export const getEventCatalogConfigFile = async (projectDirectory) => {

await writeFile(path.join(projectDirectory, 'eventcatalog.config.cjs'), configAsCommonJS);

const configAsCJS = await import(/* @vite-ignore */ path.join(projectDirectory, 'eventcatalog.config.cjs'));
const configFilePath = path.join(projectDirectory, 'eventcatalog.config.cjs');
const configFileURL = pathToFileURL(configFilePath).href;
const configAsCJS = await import(/* @vite-ignore */ configFileURL);

// Clean up?
await writeFile(path.join(projectDirectory, 'eventcatalog.config.js'), rawFile);
Expand Down

0 comments on commit bf4795f

Please sign in to comment.