Skip to content

Commit 0a9965b

Browse files
committed
Fix dir detection for windows
1 parent 7eb6a48 commit 0a9965b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function findManualExecutable(logger: Logger, uri: Uri, folder?: WorkspaceFolder
108108
if (!executableExists(exePath)) {
109109
let msg = `serverExecutablePath is set to ${exePath}`;
110110
if (directoryExists(exePath)) {
111-
msg += ' but it is a directory and the config option should point to the executable *full* path';
111+
msg += ' but it is a directory and the config option should point to the executable full path';
112112
} else {
113113
msg += " but it doesn't exist and it is not on the PATH";
114114
}

src/utils.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,17 @@ export function executableExists(exe: string): boolean {
260260
const isWindows = process.platform === 'win32';
261261
const cmd: string = isWindows ? 'where' : 'which';
262262
const out = child_process.spawnSync(cmd, [exe]);
263-
return out.status === 0 || (isWindows && fs.existsSync(exe));
263+
return out.status === 0 || (isWindows && fileExists(exe));
264264
}
265265

266266
export function directoryExists(path: string): boolean {
267267
return fs.existsSync(path) && fs.lstatSync(path).isDirectory();
268268
}
269269

270+
function fileExists(path: string): boolean {
271+
return fs.existsSync(path) && fs.lstatSync(path).isFile();
272+
}
273+
270274
export function resolvePathPlaceHolders(path: string, folder?: WorkspaceFolder) {
271275
path = path.replace('${HOME}', os.homedir).replace('${home}', os.homedir).replace(/^~/, os.homedir);
272276
if (folder) {

0 commit comments

Comments
 (0)