Skip to content

Commit

Permalink
fix: wrap 'npm ls -g' call in try/catch so it doesn't fail in Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-bromann committed Jan 25, 2024
1 parent df37f15 commit 90fac65
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

0 comments on commit 90fac65

Please sign in to comment.