Skip to content

Commit 2c87810

Browse files
committed
Dont fetch metafields during tests
1 parent e969f23 commit 2c87810

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

packages/theme-language-server-node/src/metafieldDefinitions.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,25 @@ export async function fetchMetafieldDefinitionsForURI(uri: string) {
2525
}
2626
}
2727

28-
// eslint-disable-next-line no-unused-vars
2928
async function getShopifyCliPath() {
30-
if (isWin) {
31-
const { stdout } = await exec(`where.exe shopify`);
32-
const executables = stdout
33-
.replace(/\r/g, '')
34-
.split('\n')
35-
.filter((exe) => exe.endsWith('bat'));
36-
return executables.length > 0 ? executables[0] : '';
37-
} else {
38-
const { stdout } = await exec(`which shopify`);
39-
return stdout.split('\n')[0].replace('\r', '');
29+
if (process.env.NODE_ENV === 'test') {
30+
return;
31+
}
32+
33+
try {
34+
if (isWin) {
35+
const { stdout } = await exec(`where.exe shopify`);
36+
const executables = stdout
37+
.replace(/\r/g, '')
38+
.split('\n')
39+
.filter((exe) => exe.endsWith('bat'));
40+
return executables.length > 0 ? executables[0] : '';
41+
} else {
42+
const { stdout } = await exec(`which shopify`);
43+
return stdout.split('\n')[0].replace('\r', '');
44+
}
45+
} catch (_) {
46+
// If any errors occur while trying to find the CLI, we will silently return
47+
return;
4048
}
4149
}

0 commit comments

Comments
 (0)