Skip to content
This repository was archived by the owner on Jan 17, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Tells the extension to use a local release of the Lexical language server
instead of the automatically installed one. Useful to work on Lexical, or use an
older version. This path can point to a directory that holds the lexical start
script (assumed to be `start_lexical.sh`) or any executable launcher script.
Relative paths will be interpreted to be relative to the current VSCode workspace.

The path should look something like
`/home/username/Projects/lexical/_build/dev/package/lexical/bin/start_lexical.sh`.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

21 changes: 20 additions & 1 deletion src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,27 @@ namespace Configuration {

export function getReleasePathOverride(
getConfig: GetConfig,
workspace: typeof vsWorkspace,
): string | undefined {
return getConfig("releasePathOverride") as string | undefined;
const releasePath = getConfig("releasePathOverride") as string | undefined;

if (!releasePath) {
Logger.info("Release override path is undefined.");
return undefined;
} else if (path.isAbsolute(releasePath)) {
Logger.info(
`Release override path is set to absolute path "${releasePath}".`,
);
return releasePath;
} else {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const workspacePath = workspace.workspaceFolders![0].uri.path;
const absolutePath = path.join(workspacePath, releasePath);
Logger.info(
`Release override path is set to relative path "${releasePath}". Expanded absolute path is "${absolutePath}".`,
);
return absolutePath;
}
}

export function getProjectDirUri(
Expand Down
19 changes: 11 additions & 8 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,18 @@ export function deactivate(): void {
async function maybeAutoInstall(
context: ExtensionContext,
): Promise<string | undefined> {
const releasePathOverride = Configuration.getReleasePathOverride(getConfig);
const releasePathOverride = Configuration.getReleasePathOverride(
getConfig,
workspace,
);

if (releasePathOverride !== undefined && releasePathOverride !== "") {
Logger.info(
`Release override path set to "${releasePathOverride}". Skipping auto-install.`,
);
Logger.info(`Release override path is set. Skipping auto-install.`);

return releasePathOverride as string;
}

Logger.info("Release override path is undefined, starting auto-install.");
Logger.info("Release override path is undefined. Starting auto-install.");

return await LanguageServer.install(
context.globalStorageUri,
Expand Down Expand Up @@ -115,9 +116,11 @@ async function start(
clientOptions,
);

Logger.info(
`Starting lexical release in "${startScriptOrReleaseFolderPath}"`,
);
if (fs.existsSync(startScriptPath)) {
Logger.info(`Starting lexical at "${startScriptPath}"`);
} else {
Logger.error(`Lexical start script not found: ${startScriptPath}`);
}

try {
await client.start();
Expand Down
41 changes: 41 additions & 0 deletions src/test/configuration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,45 @@ describe("Configuration", () => {

expect(projectDirUri).toEqual(URI.file("/stub/subdirectory"));
});

test("getReleasePathOverride returns undefined when no releasePathOverride is configured", () => {
const getConfigMock = jest.fn().mockReturnValue(undefined);
const workspace = WorkspaceFixture.withUri(URI.file("/stub"));
const releasePathOverride = Configuration.getReleasePathOverride(
getConfigMock,
workspace,
);

expect(releasePathOverride).toBeUndefined();
});

test("getReleasePathOverride returns the path as configured when it is asolute", () => {
const absolutePath = "/an/absolute/path";
const getConfigMock = jest.fn().mockReturnValue(absolutePath);
const workspace = WorkspaceFixture.withUri(URI.file("/stub"));
const releasePathOverride = Configuration.getReleasePathOverride(
getConfigMock,
workspace,
);

expect(releasePathOverride).toBe(absolutePath);
});

test.each([
["./a/relative/path", "/my/workspace", "/my/workspace/a/relative/path"],
["../a/relative/path", "/my/workspace", "/my/a/relative/path"],
["a/relative/path", "/my/workspace", "/my/workspace/a/relative/path"],
])(
"getReleasePathOverride returns the workspace path joined with the release path when it is relative (%s)",
(releasePath, workspacePath, expectedPath) => {
const getConfigMock = jest.fn().mockReturnValue(releasePath);
const workspace = WorkspaceFixture.withUri(URI.file(workspacePath));
const releasePathOverride = Configuration.getReleasePathOverride(
getConfigMock,
workspace,
);

expect(releasePathOverride).toBe(expectedPath);
},
);
});