Skip to content

Commit

Permalink
feat: implement KOI env as spec
Browse files Browse the repository at this point in the history
  • Loading branch information
ilharp committed Jun 30, 2022
1 parent 20af38c commit 4d67364
Showing 1 changed file with 38 additions and 3 deletions.
41 changes: 38 additions & 3 deletions packages/koi/daemon/koi_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package daemon

import (
"bufio"
"fmt"
"koi/config"
"koi/util"
envUtil "koi/util/env"
Expand All @@ -15,6 +16,42 @@ import (
"strings"
)

var (
nodeOsMap = map[string]string{
"aix": "aix",
"android": "android",
"darwin": "darwin",
"dragonfly": "dragonfly",
"freebsd": "freebsd",
"illumos": "illumos",
"ios": "ios",
"js": "js",
"linux": "linux",
"netbsd": "netbsd",
"openbsd": "openbsd",
"plan9": "plan9",
"solaris": "solaris",
"windows": "win32",
}
nodeArchMap = map[string]string{
"386": "ia32",
"amd64": "x64",
"arm": "arm",
"arm64": "arm64",
"wasm": "wasm",
"mips": "mips",
"mipsle": "mipsel",
"mips64": "mips64",
"mips64le": "mips64el",
"ppc": "ppc",
"ppc64": "ppc64",
"ppc64le": "ppc64el",
"riscv64": "riscv64",
"s390": "s390",
"s390x": "s390x",
}
)

type KoiCmdOut struct {
IsErr bool
Text string
Expand Down Expand Up @@ -152,9 +189,7 @@ func CreateKoiCmd(
env = append(env, "PATH="+pathEnv)
l.Debugf("PATH=%s", pathEnv)

koiEnv := "KOI=" + config.Version
env = append(env, koiEnv)
l.Debug(koiEnv)
envUtil.UseEnv(&env, "KOI", fmt.Sprintf("%s-%s-%s", nodeOsMap[runtime.GOOS], nodeArchMap[runtime.GOARCH], config.Version))

supcolor.UseColorEnv(&env, supcolor.Stderr)
config.UseConfigEnv(&env)
Expand Down

0 comments on commit 4d67364

Please sign in to comment.