Skip to content

Commit

Permalink
Revert "fix: preserve old behavior"
Browse files Browse the repository at this point in the history
This reverts commit 3c8d231.
  • Loading branch information
sumwatshade committed Jun 2, 2021
1 parent 17aee35 commit d06de48
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
14 changes: 13 additions & 1 deletion src/commands/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit d06de48

Please sign in to comment.