github.com/supabase/cli@v1.168.1/internal/utils/deno_darwin.go (about)

     1  //go:build darwin
     2  
     3  package utils
     4  
     5  import (
     6  	"syscall"
     7  
     8  	"github.com/go-errors/errors"
     9  )
    10  
    11  func getDenoAssetFileName() (string, error) {
    12  	// Simple runtime.GOARCH detection doesn't work if the CLI is
    13  	// running under Rosetta:
    14  	// https://github.com/supabase/cli/issues/1266. So as a workaround
    15  	// we use Apple Silicon detection:
    16  	// https://www.yellowduck.be/posts/detecting-apple-silicon-via-go.
    17  	_, err := syscall.Sysctl("sysctl.proc_translated")
    18  	if err != nil {
    19  		if err.Error() == "no such file or directory" {
    20  			// Running on Intel Mac.
    21  			return "deno-x86_64-apple-darwin.zip", nil
    22  		} else {
    23  			return "", errors.Errorf("failed to determine OS triple: %w", err)
    24  		}
    25  	} else {
    26  		// Running on Apple Silicon.
    27  		return "deno-aarch64-apple-darwin.zip", nil
    28  	}
    29  }