Skip to content

Commit

Permalink
template literals
Browse files Browse the repository at this point in the history
  • Loading branch information
Seroxdesign committed Jul 3, 2024
1 parent 85ad59b commit 010d417
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
21 changes: 9 additions & 12 deletions packages/cache/src/cli/compileWalletSetupFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,18 @@ import { FIXES_BANNER } from './compilationFixes'

const OUT_DIR_NAME = 'wallet-setup-dist'

export async function compileWalletSetupFunctions(
walletSetupDir: string,
debug: boolean
) {
const outDir = path.join(ensureCacheDirExists(), OUT_DIR_NAME);
export async function compileWalletSetupFunctions(walletSetupDir: string, debug: boolean) {
const outDir = path.join(ensureCacheDirExists(), OUT_DIR_NAME)

// Use a normalized glob pattern
const globPattern = path.join(walletSetupDir, '**', '*.setup.{ts,js,mjs}');
const globPattern = path.join(walletSetupDir, '**', '*.setup.{ts,js,mjs}')

// Use glob to find files, ensuring proper path handling
const fileList: string[] = await glob(globPattern, { absolute: false, windowsPathsNoEscape: true });
const fileList: string[] = await glob(globPattern, { absolute: false, windowsPathsNoEscape: true })

if (debug) {
console.log('[DEBUG] Found the following wallet setup files:');
console.log(fileList, '\n');
console.log('[DEBUG] Found the following wallet setup files:')
console.log(fileList, '\n')
}

// TODO: This error message is copied over from another function. Refactor this.
Expand All @@ -30,7 +27,7 @@ export async function compileWalletSetupFunctions(
`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) => {
Expand Down Expand Up @@ -63,4 +60,4 @@ export async function compileWalletSetupFunctions(
console.log('error within compile', e)
}
return outDir
}
}
2 changes: 1 addition & 1 deletion packages/cache/src/utils/importWalletSetupFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const WalletSetupModule = z.object({
})

export async function importWalletSetupFile(walletSetupFilePath: string) {
const fileToImport = process.platform === 'win32' ? 'file:\\\\\\' + walletSetupFilePath : walletSetupFilePath
const fileToImport = process.platform === 'win32' ? `file:\\\\\\${walletSetupFilePath}` : walletSetupFilePath
const walletSetupModule = await import(fileToImport)
const result = WalletSetupModule.safeParse(walletSetupModule)
if (!result.success) {
Expand Down

0 comments on commit 010d417

Please sign in to comment.