From 2c878107eb615e4f5d197f041d85c7468900605c Mon Sep 17 00:00:00 2001 From: Alok Swamy Date: Fri, 17 Jan 2025 12:02:47 -0500 Subject: [PATCH] Dont fetch metafields during tests --- .../src/metafieldDefinitions.ts | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/packages/theme-language-server-node/src/metafieldDefinitions.ts b/packages/theme-language-server-node/src/metafieldDefinitions.ts index 1fe77e7f..9b2ee954 100644 --- a/packages/theme-language-server-node/src/metafieldDefinitions.ts +++ b/packages/theme-language-server-node/src/metafieldDefinitions.ts @@ -25,17 +25,25 @@ export async function fetchMetafieldDefinitionsForURI(uri: string) { } } -// eslint-disable-next-line no-unused-vars async function getShopifyCliPath() { - if (isWin) { - const { stdout } = await exec(`where.exe shopify`); - const executables = stdout - .replace(/\r/g, '') - .split('\n') - .filter((exe) => exe.endsWith('bat')); - return executables.length > 0 ? executables[0] : ''; - } else { - const { stdout } = await exec(`which shopify`); - return stdout.split('\n')[0].replace('\r', ''); + if (process.env.NODE_ENV === 'test') { + return; + } + + try { + if (isWin) { + const { stdout } = await exec(`where.exe shopify`); + const executables = stdout + .replace(/\r/g, '') + .split('\n') + .filter((exe) => exe.endsWith('bat')); + return executables.length > 0 ? executables[0] : ''; + } else { + const { stdout } = await exec(`which shopify`); + return stdout.split('\n')[0].replace('\r', ''); + } + } catch (_) { + // If any errors occur while trying to find the CLI, we will silently return + return; } }