Skip to content

Commit e0108ea

Browse files
Fix directory check when listing sdks/runtimes
1 parent ec0b2eb commit e0108ea

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

bun.lockb

0 Bytes
Binary file not shown.

util/dotnet.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import path from 'path'
22
import { readdir } from 'node:fs/promises';
3+
import { existsSync } from 'node:fs';
34
import { getDotnetLifeCycles, type DotnetLifeCycle } from './endoflife';
45

56
export const getDownloadDirectory = (): string => {
@@ -105,19 +106,19 @@ export const getInstalledRuntimeVersions = async (withLifeCycle: boolean = true)
105106
}
106107

107108
const getDirectories = async (source: string): Promise<Directory[]> =>
108-
{
109-
if (!(await (Bun.file(source).exists()))) {
110-
return []
111-
}
112-
113-
return (await readdir(source, { withFileTypes: true }))
114-
.filter(dirent => dirent.isDirectory())
115-
.map(dirent => ({
116-
name: dirent.name,
117-
path: path.resolve(source, dirent.name)
118-
}) as Directory);
109+
{
110+
if (!(await existsSync(source))) {
111+
return []
119112
}
120113

114+
return (await readdir(source, { withFileTypes: true }))
115+
.filter(dirent => dirent.isDirectory())
116+
.map(dirent => ({
117+
name: dirent.name,
118+
path: path.resolve(source, dirent.name)
119+
}) as Directory);
120+
}
121+
121122
type Directory = {
122123
name: string
123124
path: string

0 commit comments

Comments
 (0)