Skip to content

Commit f5aa01f

Browse files
Yanpassam-mccall
andauthored
fix which doesn't find path (#10)
* fix which doesn't find path * Nits Avoid double negation. Use fs.access instead of fs.exists. Co-authored-by: Sam McCall <sam.mccall@gmail.com>
1 parent fd4795c commit f5aa01f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/index.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,20 @@ type InstallStatus = {
6767
// If not, offer to install one. If so, check for updates.
6868
export async function prepare(ui: UI,
6969
checkUpdate: boolean): Promise<InstallStatus> {
70+
let clangdPath = ui.clangdPath;
7071
try {
71-
var absPath = await promisify(which)(ui.clangdPath) as string;
72+
if (path.isAbsolute(clangdPath)) {
73+
await promisify(fs.access)(clangdPath);
74+
} else {
75+
clangdPath = await promisify(which)(clangdPath) as string;
76+
}
7277
} catch (e) {
73-
// Couldn't find clangd - start recovery flow and stop extension
74-
// loading.
78+
// Couldn't find clangd - start recovery flow and stop extension loading.
7579
return {clangdPath: null, background: recover(ui)};
7680
}
7781
// Allow extension to load, asynchronously check for updates.
7882
return {
79-
clangdPath: absPath,
83+
clangdPath,
8084
background: checkUpdate ? checkUpdates(/*requested=*/ false, ui)
8185
: Promise.resolve()
8286
};

0 commit comments

Comments
 (0)