Skip to content

Commit 1f4033a

Browse files
franciscoovazevedoandrzej-janczak
authored andcommitted
installing eslint in wsl
1 parent 0a57dfa commit 1f4033a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

config/tools-installer.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"codacy/cli-v2/utils"
77
"codacy/cli-v2/utils/logger"
88
"fmt"
9+
"log"
910
"os"
1011
"os/exec"
1112
"path/filepath"
@@ -164,6 +165,25 @@ func installRuntimeTool(name string, toolInfo *plugins.ToolInfo, registry string
164165

165166
// Execute the installation command using the package manager
166167
cmd := exec.Command(packageManagerBinary, strings.Split(installCmd, " ")...)
168+
169+
// Special handling for ESLint installation in WSL environment
170+
if toolInfo.Name == "eslint" {
171+
// Get node binary directory to add to PATH
172+
nodeBinary, ok := runtimeInfo.Binaries["node"]
173+
if ok {
174+
nodeDir := filepath.Dir(nodeBinary)
175+
// Get current PATH
176+
currentPath := os.Getenv("PATH")
177+
// For WSL, always use Linux path separator
178+
pathSeparator := ":"
179+
newPath := nodeDir + pathSeparator + currentPath
180+
cmd.Env = append(os.Environ(), "PATH="+newPath)
181+
log.Printf("Setting PATH environment for ESLint installation: %s\n", nodeDir)
182+
}
183+
}
184+
185+
log.Printf("Installing %s v%s...\n", toolInfo.Name, toolInfo.Version)
186+
log.Printf("Running command: %s %s\n", packageManagerBinary, installCmd)
167187
output, err := cmd.CombinedOutput()
168188
if err != nil {
169189
return fmt.Errorf("failed to install tool: %s: %w", string(output), err)

0 commit comments

Comments
 (0)