From 90fac650eb6474d23fbf3ca2abe5093cd754b1a2 Mon Sep 17 00:00:00 2001 From: Christian Bromann Date: Wed, 24 Jan 2024 18:10:15 -0800 Subject: [PATCH] fix: wrap 'npm ls -g' call in try/catch so it doesn't fail in Windows --- src/index.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 5bd41a65..99cf5f19 100644 --- a/src/index.ts +++ b/src/index.ts @@ -107,10 +107,16 @@ async function isCLIInstalled(path: string) { return true } catch (error) { // check of the cli is installed globally - const output = execSync('npm ls -g', { encoding: 'utf-8' }) - if (output.includes('@wdio/cli')) { - return true + // wrap in try/catch as it can fail on Windows + try { + const output = execSync('npm ls -g', { encoding: 'utf-8' }) + if (output.includes('@wdio/cli')) { + return true + } + } catch (err) { + return false } + return false } -} \ No newline at end of file +}