Skip to content

Commit

Permalink
glob
Browse files Browse the repository at this point in the history
  • Loading branch information
sero committed Jul 2, 2024
1 parent 9f4cb92 commit d2cf5f7
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
22 changes: 16 additions & 6 deletions packages/cache/src/cli/compileWalletSetupFunctions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from 'node:path'
import { glob } from 'glob'
import { globSync } from 'glob'
import { build } from 'tsup'
import { ensureCacheDirExists } from '../ensureCacheDirExists'
import { FIXES_BANNER } from './compilationFixes'
Expand All @@ -9,14 +9,24 @@ const OUT_DIR_NAME = 'wallet-setup-dist'
const createGlobPattern = (walletSetupDir: string) => path.join(walletSetupDir, '**', '*.setup.{ts,js,mjs}')

export async function compileWalletSetupFunctions(walletSetupDir: string, debug: boolean) {
const escapeWindowsFilePath = (filePath: string) => {
filePath.replace(/\//g, '\\')
const n = filePath.replace(/\\/g, '\\\\')
console.log(n, 'n', filePath)
return n
}
const outDir = path.join(ensureCacheDirExists(), OUT_DIR_NAME)

const globPattern = createGlobPattern(walletSetupDir)
const fileList = await glob(globPattern)

console.log(process.platform, 'platform')
const setupPath = process.platform === 'win32' ? escapeWindowsFilePath(walletSetupDir) : walletSetupDir
console.log(setupPath, 'setupPath')
const globPattern = createGlobPattern(setupPath)
const fullPath = path.join(process.cwd(), globPattern)
console.log(fullPath, 'fp')
const fileList = globSync('*.setup.{ts,js,mjs}')
console.log(fileList, 'fl')
if (debug) {
console.log('[DEBUG] Found the following wallet setup files:')
console.log(fileList, '\n')
console.log(fileList, globPattern, outDir, '\n')
}

// TODO: This error message is copied over from another function. Refactor this.
Expand Down
6 changes: 3 additions & 3 deletions packages/cache/src/ensureCacheDirExists.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import path from 'node:path'
import fs from 'fs-extra'
import { CACHE_DIR_NAME } from './constants'
import appRoot from 'app-root-path'
// import appRoot from 'app-root-path'

export function ensureCacheDirExists() {
const cacheDirPath =
process.platform === 'win32' ? appRoot.resolve('/node_modules') : path.join(process.cwd(), CACHE_DIR_NAME)
const cacheDirPath = path.join(process.cwd(), CACHE_DIR_NAME)
console.log(cacheDirPath)
fs.ensureDirSync(cacheDirPath)
return cacheDirPath
}
2 changes: 1 addition & 1 deletion wallets/metamask/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
"scripts": {
"build": "pnpm run clean && pnpm run build:dist && pnpm run build:types",
"build:cache": "synpress-cache test/wallet-setup",
"build:cache": "synpress-cache test/wallet-setup --debug",
"build:cache:headless": "synpress-cache test/wallet-setup --headless",
"build:cache:headless:force": "synpress-cache test/wallet-setup --headless --force",
"build:dist": "tsup --tsconfig tsconfig.build.json",
Expand Down
9 changes: 0 additions & 9 deletions wallets/metamask/test/wallet-setup/basic.setup.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion wallets/metamask/test/wallet-setup/basic.setup.d.ts.map

This file was deleted.

0 comments on commit d2cf5f7

Please sign in to comment.