Skip to content

Commit

Permalink
fixup: exe on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
dpastoor committed Jun 9, 2022
1 parent 5bb8318 commit 1291b63
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
9 changes: 7 additions & 2 deletions cmd/use.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"path/filepath"
"runtime"
"sort"

"github.com/AlecAivazis/survey/v2"
Expand Down Expand Up @@ -53,13 +54,17 @@ func newUse(useOpts useOpts, version string) error {
if err != nil {
return err
}
err = os.Remove(filepath.Join(config.GetPathToActiveBinDir(), "quarto"))
quartoExe := "quarto"
if runtime.GOOS == "windows" {
quartoExe = "quarto.exe"
}
err = os.Remove(filepath.Join(config.GetPathToActiveBinDir(), quartoExe))
if err != nil && !os.IsNotExist(err) {
return err
}
err = os.Symlink(
quartopath,
filepath.Join(config.GetPathToActiveBinDir(), "quarto"),
filepath.Join(config.GetPathToActiveBinDir(), quartoExe),
)
if err != nil {
return err
Expand Down
13 changes: 12 additions & 1 deletion internal/config/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import (
"fmt"
"os"
"path/filepath"
"runtime"

"github.com/adrg/xdg"
log "github.com/sirupsen/logrus"
)

func GetConfigPath() (string, error) {
Expand Down Expand Up @@ -46,7 +48,16 @@ func GetInstalledVersions() (map[string]string, error) {
}
for _, entry := range entries {
if entry.IsDir() {
iv[entry.Name()] = filepath.Join(GetPathToVersionsDir(), entry.Name(), "bin", "quarto")
quartoExe := "quarto"
if runtime.GOOS == "windows" {
quartoExe = "quarto.exe"
}
quartoPath := filepath.Join(GetPathToVersionsDir(), entry.Name(), "bin", quartoExe)
if _, err := os.Stat(quartoPath); err == nil {
iv[entry.Name()] = quartoPath
} else {
log.Warn("could not find expected quarto executable for version: ", entry.Name())
}
}
}
return iv, nil
Expand Down

0 comments on commit 1291b63

Please sign in to comment.