Skip to content

Commit

Permalink
Merge branch 'master' into bump-versions
Browse files Browse the repository at this point in the history
  • Loading branch information
jneira authored Oct 13, 2021
2 parents 94d146c + b471d04 commit 05731b5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
"scope": "resource",
"type": "string",
"default": "",
"markdownDescription": "Manually set a language server executable. Can be something on the $PATH or a path to an executable itself. Works with `~,` `${HOME}` and `${workspaceFolder}`. **Deprecated scope**: This option will be set to `machine` scope in a future release, so it can be changed only globally, not per workspace."
"markdownDescription": "Manually set a language server executable. Can be something on the $PATH or the full path to the executable itself. Works with `~,` `${HOME}` and `${workspaceFolder}`. **Deprecated scope**: This option will be set to `machine` scope in a future release, so it can be changed only globally, not per workspace."
},
"haskell.serverExtraArgs": {
"scope": "resource",
Expand Down
12 changes: 9 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { CommandNames } from './commands/constants';
import { ImportIdentifier } from './commands/importIdentifier';
import { DocsBrowser } from './docsBrowser';
import { downloadHaskellLanguageServer } from './hlsBinaries';
import { executableExists, ExtensionLogger, resolvePathPlaceHolders } from './utils';
import { directoryExists, executableExists, ExtensionLogger, resolvePathPlaceHolders } from './utils';

// The current map of documents & folders to language servers.
// It may be null to indicate that we are in the process of launching a server,
Expand Down Expand Up @@ -103,10 +103,16 @@ function findManualExecutable(logger: Logger, uri: Uri, folder?: WorkspaceFolder
}
logger.info(`Trying to find the server executable in: ${exePath}`);
exePath = resolvePathPlaceHolders(exePath, folder);
logger.info(`Location after path variables subsitution: ${exePath}`);
logger.info(`Location after path variables substitution: ${exePath}`);

if (!executableExists(exePath)) {
throw new Error(`serverExecutablePath is set to ${exePath} but it doesn't exist and it is not on the PATH`);
let msg = `serverExecutablePath is set to ${exePath}`;
if (directoryExists(exePath)) {
msg += ' but it is a directory and the config option should point to the executable *full* path';
} else {
msg += " but it doesn't exist and it is not on the PATH";
}
throw new Error(msg);
}
return exePath;
}
Expand Down
4 changes: 4 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@ export function executableExists(exe: string): boolean {
return out.status === 0 || (isWindows && fs.existsSync(exe));
}

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

export function resolvePathPlaceHolders(path: string, folder?: WorkspaceFolder) {
path = path.replace('${HOME}', os.homedir).replace('${home}', os.homedir).replace(/^~/, os.homedir);
if (folder) {
Expand Down

0 comments on commit 05731b5

Please sign in to comment.