Skip to content

Commit

Permalink
fix(cli-install): fixing the CLI installation URL
Browse files Browse the repository at this point in the history
  • Loading branch information
KerryRitter committed Feb 15, 2021
1 parent 3986d40 commit 7d1772a
Showing 1 changed file with 27 additions and 19 deletions.
46 changes: 27 additions & 19 deletions cli/global/services/mvf-manager.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,10 @@ export class MvfManagerService {
/**
* Updates the local installation of `mvf`.
*
* @param requestedVerson The requested version in the format of #.#.# (no v prefix)
* @param requestedVersion The requested version in the format of #.#.# (no v prefix)
*/
async update(requestedVerson: string | null) {
let installUrl = "https://deno.land/x/momentum/cli/main.ts";
const versionInfo = await this.getVersionInfoFromDenoLand();

const version = versionInfo.latest;
if (requestedVerson?.length) {
if (!versionInfo.versions.find((v) => v === `v${version}`)) {
throw new Error("Could not find specified version.");
}

installUrl = [
"https://deno.land/x/momentum@v",
version,
"cli/main.ts",
].join("/");
}
async update(requestedVersion: string | null) {
const installUrl = await this.getInstallUrlForRequestedVersion(requestedVersion);

await this.runInstall(
installUrl,
Expand All @@ -63,9 +49,10 @@ export class MvfManagerService {
*/
async install() {
await this.initializeMvDirectory();
const installUrl = await this.getInstallUrlForRequestedVersion(null);
await this.runInstall(
`./main.ts`,
false,
installUrl,
true,
);
}

Expand Down Expand Up @@ -94,6 +81,27 @@ export class MvfManagerService {
};
}

private async getInstallUrlForRequestedVersion(requestedVersion: string | null) {
let installUrl = "https://deno.land/x/momentum/cli/main.ts";

const versionInfo = await this.getVersionInfoFromDenoLand();

const version = versionInfo.latest;
if (requestedVersion?.length) {
if (!versionInfo.versions.find((v) => v === `v${version}`)) {
throw new Error("Could not find specified version.");
}

installUrl = [
"https://deno.land/x/momentum@v",
version,
"cli/main.ts",
].join("/");
}

return installUrl;
}

private async initializeMvDirectory() {
const {
mvDirAbsolutePath,
Expand Down

0 comments on commit 7d1772a

Please sign in to comment.