Skip to content

fix: Installing eslint in WSL [PLUTO-1419] #99

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions codacy-cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ case "$arch" in
"x86")
arch="386"
;;
"aarch64"|"arm64")
arch="arm64"
;;
esac

if [ -z "$CODACY_CLI_V2_TMP_FOLDER" ]; then
Expand Down
27 changes: 27 additions & 0 deletions config/tools-installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import (
"codacy/cli-v2/utils"
"codacy/cli-v2/utils/logger"
"fmt"
"log"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"text/template"

Expand Down Expand Up @@ -164,6 +166,31 @@ func installRuntimeTool(name string, toolInfo *plugins.ToolInfo, registry string

// Execute the installation command using the package manager
cmd := exec.Command(packageManagerBinary, strings.Split(installCmd, " ")...)

// Special handling for ESLint installation in Linux (WSL) environment
if toolInfo.Name == "eslint" && runtime.GOOS == "linux" {
// Get node binary directory to add to PATH
nodeBinary, exist := runtimeInfo.Binaries["node"]
if exist {
nodeDir := filepath.Dir(nodeBinary)
// Get current PATH
currentPath := os.Getenv("PATH")
// For Linux (WSL), always use Linux path separator
pathSeparator := ":"
newPath := nodeDir + pathSeparator + currentPath
cmd.Env = append(os.Environ(), "PATH="+newPath)
logger.Debug("Setting PATH environment for ESLint installation", logrus.Fields{
"nodeDir": nodeDir,
"currentPath": currentPath,
"newPath": newPath,
})
}
}

log.Printf("Installing %s v%s...\n", toolInfo.Name, toolInfo.Version)
logger.Debug("Running command", logrus.Fields{
"command": fmt.Sprintf("%s %s", packageManagerBinary, installCmd),
})
output, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("failed to install tool: %s: %w", string(output), err)
Expand Down
Loading