Skip to content

Commit

Permalink
Don’t break in future when deno add platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
mxcl committed Feb 28, 2023
1 parent 1915886 commit e008ee6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
11 changes: 5 additions & 6 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ export function host(): HostReturnValue {
case "aarch64": return "aarch64"
case "x86_64": return "x86-64"
// ^^ ∵ https://en.wikipedia.org/wiki/X86-64 and semver.org prohibits underscores
default:
throw new Error(`unsupported-arch: ${Deno.build.arch}`)
}
})()

Expand All @@ -316,12 +318,9 @@ export function host(): HostReturnValue {
case "linux":
case "windows":
return Deno.build.os
case "freebsd":
case "netbsd":
case "aix":
case "solaris":
case "illumos":
throw new Error(`unsupported-os: ${Deno.build.os}`)
default:
console.warn("assuming linux mode for:", Deno.build.os)
return 'linux'
}
})()

Expand Down
10 changes: 2 additions & 8 deletions src/vendor/Path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,10 @@ export default class Path {
static home(): Path {
return new Path((() => {
switch (Deno.build.os) {
case "linux":
case "darwin":
case "freebsd":
case "netbsd":
case "aix":
case "solaris":
case "illumos":
return Deno.env.get("HOME")!
case "windows":
return Deno.env.get("USERPROFILE")!
default:
return Deno.env.get("HOME")!
}
})())
}
Expand Down

0 comments on commit e008ee6

Please sign in to comment.