From d06de4814d99ea225041b2c4f0c0169f3116e2f6 Mon Sep 17 00:00:00 2001 From: lshadler Date: Tue, 1 Jun 2021 20:19:33 -0700 Subject: [PATCH] Revert "fix: preserve old behavior" This reverts commit 3c8d231a010c205c557dcf690cf28e98c22c774f. --- package.json | 2 +- src/commands/update.ts | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d5f019e6..e48f3040 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "http-call": "^5.3.0", "lodash": "^4.17.21", "log-chopper": "^1.0.2", - "semver": "^7.3.4", + "semver": "^7.3.5", "tar-fs": "^2.1.1" }, "devDependencies": { diff --git a/src/commands/update.ts b/src/commands/update.ts index 95955f8e..82aa931c 100644 --- a/src/commands/update.ts +++ b/src/commands/update.ts @@ -65,6 +65,18 @@ export default class UpdateCommand extends Command { this.log() this.log(`Updating to an already installed version will not update the channel. If autoupdate is enabled, the CLI will eventually be updated back to ${this.channel}.`) } else { + let targetVersion + if (flags['switch-to']) { + targetVersion = semver.clean(flags['switch-to']) + this.debug(`Flag overriden target version: ${targetVersion}`) + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const [_, channel] = targetVersion?.split('-') || ['', ''] + if (channel) { + this.channel = channel.substr(0, channel.indexOf('.')) + } + this.debug(`Flag overriden target channel: ${this.channel}`) + } + cli.action.start(`${this.config.name}: Updating CLI`) await this.config.runHook('preupdate', {channel: this.channel}) const manifest = await this.fetchManifest() @@ -141,7 +153,7 @@ export default class UpdateCommand extends Command { bin: this.config.bin, platform: this.config.platform, arch: this.config.arch, - ext: this.updatedVersion ? '.tar.gz' : 'gz', + ext: '.tar.gz', })) const {response: stream} = await http.stream(gzUrl)