Skip to content
This repository has been archived by the owner on Mar 21, 2023. It is now read-only.

feat: support new 2.13 artifacts #429

Merged
merged 2 commits into from
Mar 10, 2022
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
32 changes: 32 additions & 0 deletions src/__tests__/fetchMetals.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { calcServerDependency } from "../fetchMetals";

describe("fetchMetals", () => {
describe("calcServerDependency", () => {
function expectedDep(binaryVersion: string, serverVersion: string): string {
return `org.scalameta:metals_${binaryVersion}:${serverVersion}`;
}
it("should download from appropriate binaryVersion", () => {
expect(calcServerDependency("0.11.1")).toBe(
expectedDep("2.12", "0.11.1")
);
expect(calcServerDependency("0.11.2")).toBe(
expectedDep("2.12", "0.11.2")
);
expect(calcServerDependency("0.11.2-SNAPSHOT")).toBe(
expectedDep("2.12", "0.11.2-SNAPSHOT")
);
expect(calcServerDependency("0.11.2-RC1")).toBe(
expectedDep("2.12", "0.11.2-RC1")
);
expect(calcServerDependency("0.11.3")).toBe(
expectedDep("2.13", "0.11.3")
);
expect(calcServerDependency("0.11.3-SNAPSHOT")).toBe(
expectedDep("2.13", "0.11.3-SNAPSHOT")
);
expect(calcServerDependency("0.11.3-RC1")).toBe(
expectedDep("2.13", "0.11.3-RC1")
);
});
});
});
13 changes: 9 additions & 4 deletions src/fetchMetals.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as semver from "semver";
import { ChildProcessPromise, spawn } from "promisify-child-process";
import { JavaConfig } from "./getJavaConfig";

Expand All @@ -16,10 +17,7 @@ export function fetchMetals({
(p) => !p.startsWith("-agentlib")
);

const serverDependency = serverVersion.includes(":")
? serverVersion
: `org.scalameta:metals_2.12:${serverVersion}`;

const serverDependency = calcServerDependency(serverVersion);
return spawn(
javaPath,
[
Expand Down Expand Up @@ -54,3 +52,10 @@ export function fetchMetals({
}
);
}

export function calcServerDependency(serverVersion: string): string {
const binaryVersion = semver.gt(serverVersion, "0.11.2") ? "2.13" : "2.12";
return serverVersion.includes(":")
? serverVersion
: `org.scalameta:metals_${binaryVersion}:${serverVersion}`;
}