diff --git a/packages/cache/src/cli/compileWalletSetupFunctions.ts b/packages/cache/src/cli/compileWalletSetupFunctions.ts index ec5bfd799..a8d2c107b 100644 --- a/packages/cache/src/cli/compileWalletSetupFunctions.ts +++ b/packages/cache/src/cli/compileWalletSetupFunctions.ts @@ -1,4 +1,4 @@ -import path from 'node:path' +import path, { posix, win32 } from 'node:path' import { glob } from 'glob' import { build } from 'tsup' import { ensureCacheDirExists } from '../ensureCacheDirExists' @@ -16,7 +16,7 @@ export async function compileWalletSetupFunctions( const globPattern = path.join(walletSetupDir, '**', '*.setup.{ts,js,mjs}'); // Use glob to find files, ensuring proper path handling - const fileList = await glob(globPattern, { absolute: true, windowsPathsNoEscape: true }); + const fileList: string[] = await glob(globPattern, { absolute: false, windowsPathsNoEscape: true }); if (debug) { console.log('[DEBUG] Found the following wallet setup files:'); @@ -32,23 +32,16 @@ export async function compileWalletSetupFunctions( ].join('\n') ); } - // TODO: This error message is copied over from another function. Refactor this. - if (!fileList.length) { - throw new Error( - [ - `No wallet setup files found at ${walletSetupDir}`, - 'Remember that all wallet setup files must end with `.setup.{ts,js,mjs}` extension!' - ].join('\n') - ) - } - + const normalized = fileList.map((file) => { + return file.split(win32.sep).join(posix.sep) + }) try { await build({ name: 'cli-build', silent: true, - entry: fileList, + entry: normalized, clean: true, outDir, format: 'esm', @@ -67,7 +60,7 @@ export async function compileWalletSetupFunctions( } }) } catch (e) { - console.log(e) + console.log('error within compile', e) } return outDir } \ No newline at end of file diff --git a/packages/cache/src/createCache.ts b/packages/cache/src/createCache.ts index 90ee2b550..d0c16effc 100644 --- a/packages/cache/src/createCache.ts +++ b/packages/cache/src/createCache.ts @@ -3,14 +3,11 @@ import { triggerCacheCreation } from './utils/triggerCacheCreation' export async function createCache(walletSetupDirPath: string, downloadExtension: () => Promise, force = false) { const setupFunctions = await getUniqueWalletSetupFunctions(walletSetupDirPath) - const cacheCreationPromises = await triggerCacheCreation(setupFunctions, downloadExtension, force) - if (cacheCreationPromises.length === 0) { console.log('No new setup functions to cache. Exiting...') return } - // TODO: This line has no unit test. Not sure how to do it. Look into it later. await Promise.all(cacheCreationPromises) diff --git a/packages/cache/src/utils/getWalletSetupFiles.ts b/packages/cache/src/utils/getWalletSetupFiles.ts index 41bd2f050..ccd6c8029 100644 --- a/packages/cache/src/utils/getWalletSetupFiles.ts +++ b/packages/cache/src/utils/getWalletSetupFiles.ts @@ -26,6 +26,5 @@ export async function getWalletSetupFiles(walletSetupDirPath: string) { ].join('\n') ) } - return fileList } diff --git a/packages/cache/src/utils/importWalletSetupFile.ts b/packages/cache/src/utils/importWalletSetupFile.ts index 498e86e65..488bd69bb 100644 --- a/packages/cache/src/utils/importWalletSetupFile.ts +++ b/packages/cache/src/utils/importWalletSetupFile.ts @@ -10,8 +10,8 @@ const WalletSetupModule = z.object({ }) export async function importWalletSetupFile(walletSetupFilePath: string) { - const walletSetupModule = await import(walletSetupFilePath) - + const fileToImport = process.platform === 'win32' ? 'file:\\\\\\' + walletSetupFilePath : walletSetupFilePath + const walletSetupModule = await import(fileToImport) const result = WalletSetupModule.safeParse(walletSetupModule) if (!result.success) { throw new Error(