Skip to content

Commit

Permalink
fix: Avoid uncaught excpetion on detecting java
Browse files Browse the repository at this point in the history
  • Loading branch information
ci010 committed Jan 3, 2024
1 parent dc77fb3 commit 9d47f43
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/installer/java.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,15 @@ export async function getPotentialJavaLocations(): Promise<string[]> {

const which = () => new Promise<string>((resolve) => {
exec('which java', (_error, stdout) => {
resolve(stdout.replace('\n', ''))
})
if (!_error) resolve(stdout.replace('\n', ''))
else resolve('')
}).once('error', () => resolve(''))
})
const where = () => new Promise<string[]>((resolve) => {
exec('where java', (_error, stdout) => {
resolve(stdout.split('\r\n'))
})
if (!_error) resolve(stdout.split('\r\n'))
else resolve([])
}).once('error', () => resolve([]))
})

if (currentPlatform === 'win32') {
Expand Down

0 comments on commit 9d47f43

Please sign in to comment.