From 6072a80428967ce92c4c238f1607946751169046 Mon Sep 17 00:00:00 2001 From: RyanDagg Date: Mon, 10 Apr 2023 09:33:18 -0600 Subject: [PATCH] fix: handle WSL when requesting version updates (#540) * fix: handle Windows Subsystem for Linux platforms when requesting version updates. * fix: lint error --- src/update.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/update.ts b/src/update.ts index 368b2122..10c41aef 100644 --- a/src/update.ts +++ b/src/update.ts @@ -143,21 +143,21 @@ export class Updater { } private s3ChannelManifestKey(channel: string): string { - const {bin, platform, arch} = this.config + const {bin, arch} = this.config const s3SubDir = this.composeS3SubDir() - return path.join(s3SubDir, 'channels', channel, `${bin}-${platform}-${arch}-buildmanifest`) + return path.join(s3SubDir, 'channels', channel, `${bin}-${this.determinePlatform()}-${arch}-buildmanifest`) } private s3VersionManifestKey(version: string, hash: string): string { - const {bin, platform, arch} = this.config + const {bin, arch} = this.config const s3SubDir = this.composeS3SubDir() - return path.join(s3SubDir, 'versions', version, hash, `${bin}-v${version}-${hash}-${platform}-${arch}-buildmanifest`) + return path.join(s3SubDir, 'versions', version, hash, `${bin}-v${version}-${hash}-${this.determinePlatform()}-${arch}-buildmanifest`) } private s3VersionIndexKey(): string { - const {bin, platform, arch} = this.config + const {bin, arch} = this.config const s3SubDir = this.composeS3SubDir() - return path.join(s3SubDir, 'versions', `${bin}-${platform}-${arch}-tar-gz.json`) + return path.join(s3SubDir, 'versions', `${bin}-${this.determinePlatform()}-${arch}-tar-gz.json`) } private async fetchChannelManifest(channel: string): Promise { @@ -197,7 +197,7 @@ export class Updater { version, channel, bin: this.config.bin, - platform: this.config.platform, + platform: this.determinePlatform(), arch: this.config.arch, ext: 'gz', })) @@ -208,7 +208,7 @@ export class Updater { version, channel, bin: this.config.bin, - platform: this.config.platform, + platform: this.determinePlatform(), arch: this.config.arch, }) const extraction = extract(stream, baseDir, output, sha256gz) @@ -278,6 +278,10 @@ export class Updater { return this.config.channel || 'stable' } + private determinePlatform(): Interfaces.PlatformTypes { + return this.config.platform === 'wsl' ? 'linux' : this.config.platform + } + private async determineCurrentVersion(): Promise { try { const currentVersion = await fs.readFile(this.clientBin, 'utf8')