Skip to content

Commit ba809d6

Browse files
committed
为 Apple Silicon 兼容 16.0.0 以下的版本
1 parent 7727ee3 commit ba809d6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

internal/node/target_darwin.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package node
33
import (
44
"fmt"
55
"runtime"
6+
7+
"github.com/Masterminds/semver"
68
)
79

810
func GetRemoteArtifactTarget(version string) *RemoteArtifactTarget {
@@ -27,6 +29,13 @@ func getNodeFileName(version string) *string {
2729

2830
return &str
2931
} else if runtime.GOARCH == "arm64" {
32+
// Node.js 16.0.0 and later versions have official support for Apple Silicon
33+
// https://nodejs.org/en/blog/release/v16.0.0/
34+
if c, err := semver.NewConstraint("< 16.0.0"); err == nil && c.Check(semver.MustParse(version)) {
35+
str := fmt.Sprintf("node-v%s-darwin-x64", version)
36+
return &str
37+
}
38+
3039
str := fmt.Sprintf("node-v%s-darwin-arm64", version)
3140

3241
return &str

0 commit comments

Comments
 (0)