From 5ab8086e5035a8108648f348e139390aaae33fb4 Mon Sep 17 00:00:00 2001 From: Daniel Izdebski Date: Mon, 1 Jan 2024 04:05:28 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20feat(core):?= =?UTF-8?q?=20Improve=20message=20when=20no=20setup=20files=20are=20found?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/cli/compileWalletSetupFunctions.ts | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/core/src/cli/compileWalletSetupFunctions.ts b/packages/core/src/cli/compileWalletSetupFunctions.ts index 9678ea909..b25254c7e 100644 --- a/packages/core/src/cli/compileWalletSetupFunctions.ts +++ b/packages/core/src/cli/compileWalletSetupFunctions.ts @@ -6,17 +6,33 @@ import { FIXES_BANNER } from './compilationFixes' const OUT_DIR_NAME = 'wallet-setup-dist' -const createGlobPattern = (walletSetupDir: string) => path.join(walletSetupDir, '**', '*.{js,ts}') +const createGlobPattern = (walletSetupDir: string) => path.join(walletSetupDir, '**', '*.setup.{js,ts}') export async function compileWalletSetupFunctions(walletSetupDir: string, debug: boolean) { const outDir = path.join(ensureCacheDirExists(), OUT_DIR_NAME) const globPattern = createGlobPattern(walletSetupDir) + const fileList = await glob(globPattern) + + if (debug) { + 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. + if (!fileList.length) { + throw new Error( + [ + `No wallet setup files found at ${walletSetupDir}`, + 'Remember that all wallet setup files must end with `.setup.{js,ts}` extension!' + ].join('\n') + ) + } await build({ name: 'cli-build', silent: true, - entry: await glob(globPattern), + entry: fileList, clean: true, outDir, format: 'esm',