-
-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
56 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//go:build darwin | ||
|
||
package utils | ||
|
||
import ( | ||
"fmt" | ||
"syscall" | ||
) | ||
|
||
func getDenoAssetFileName() (string, error) { | ||
// Simple runtime.GOARCH detection doesn't work if the CLI is | ||
// running under Rosetta: | ||
// https://github.com/supabase/cli/issues/1266. So as a workaround | ||
// we use Apple Silicon detection: | ||
// https://www.yellowduck.be/posts/detecting-apple-silicon-via-go. | ||
_, err := syscall.Sysctl("sysctl.proc_translated") | ||
if err != nil { | ||
if err.Error() == "no such file or directory" { | ||
// Running on Intel Mac. | ||
return "deno-x86_64-apple-darwin.zip", nil | ||
} else { | ||
return "", fmt.Errorf("failed to determine OS triple: %w", err) | ||
} | ||
} else { | ||
// Running on Apple Silicon. | ||
return "deno-aarch64-apple-darwin.zip", nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//go:build !darwin | ||
|
||
package utils | ||
|
||
import ( | ||
"errors" | ||
"runtime" | ||
) | ||
|
||
func getDenoAssetFileName() (string, error) { | ||
if runtime.GOOS == "linux" && runtime.GOARCH == "amd64" { | ||
return "deno-x86_64-unknown-linux-gnu.zip", nil | ||
} else if runtime.GOOS == "linux" && runtime.GOARCH == "arm64" { | ||
// TODO: version pin to official release once available https://github.com/denoland/deno/issues/1846 | ||
return "deno-linux-arm64.zip", nil | ||
} else if runtime.GOOS == "windows" && runtime.GOARCH == "amd64" { | ||
return "deno-x86_64-pc-windows-msvc.zip", nil | ||
} else { | ||
return "", errors.New("Platform " + runtime.GOOS + "/" + runtime.GOARCH + " is currently unsupported for Functions.") | ||
} | ||
} |