Skip to content

Commit 90bcea6

Browse files
committed
Use elixir_check command
Fixes #406
1 parent bf17614 commit 90bcea6

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

src/executable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as vscode from "vscode";
55
const platformCommand = (command: Kind) =>
66
command + (os.platform() === "win32" ? ".bat" : ".sh");
77

8-
export type Kind = "language_server" | "debug_adapter";
8+
export type Kind = "language_server" | "debug_adapter" | "elixir_check";
99
export function buildCommand(
1010
context: vscode.ExtensionContext,
1111
kind: Kind,

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export function activate(context: vscode.ExtensionContext): ElixirLS {
5757
}),
5858
);
5959

60-
testElixir();
60+
testElixir(context);
6161

6262
detectConflictingExtensions();
6363

src/testElixir.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { execSync } from "node:child_process";
22
import * as vscode from "vscode";
3+
import { buildCommand } from "./executable";
34

45
function testElixirCommand(command: string): false | Buffer {
56
try {
@@ -9,24 +10,27 @@ function testElixirCommand(command: string): false | Buffer {
910
}
1011
}
1112

12-
export function testElixir(): boolean {
13-
const testResult = testElixirCommand("elixir");
13+
export function testElixir(context: vscode.ExtensionContext): boolean {
14+
// Use the same script infrastructure as the language server to ensure
15+
// consistent environment setup (version managers, etc.)
16+
const checkCommand = buildCommand(context, "elixir_check", undefined);
17+
const testResult = testElixirCommand(`"${checkCommand}"`);
1418

1519
if (!testResult) {
1620
vscode.window.showErrorMessage(
17-
"Failed to run 'elixir' command. ElixirLS will probably fail to launch. Logged PATH to Development Console.",
21+
"Failed to run elixir check command. ElixirLS will probably fail to launch. Logged PATH to Development Console.",
1822
);
1923
console.warn(
20-
`Failed to run 'elixir' command. Current process's PATH: ${process.env.PATH}`,
24+
`Failed to run elixir check command. Current process's PATH: ${process.env.PATH}`,
2125
);
2226
return false;
2327
}
2428
if (testResult.length > 0) {
2529
vscode.window.showErrorMessage(
26-
"Running 'elixir' command caused extraneous print to stdout. See VS Code's developer console for details.",
30+
"Running elixir check command caused extraneous print to stdout. See VS Code's developer console for details.",
2731
);
2832
console.warn(
29-
`Running 'elixir -e \"\"' printed to stdout:\n${testResult.toString()}`,
33+
`Running elixir check command printed to stdout:\n${testResult.toString()}`,
3034
);
3135
return false;
3236
}

0 commit comments

Comments
 (0)