Skip to content

Commit 9552523

Browse files
committed
fix: Resolve dupBranchBody in VSCode extension installation
- Extract common command execution logic to eliminate duplicate branches - Both Windows and non-Windows branches now only differ in executable name - Fixes gocritic dupBranchBody warning in downloadAndInstallExtension function
1 parent 36304bf commit 9552523

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

general/ide/jetbrains/jetbrains.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,8 @@ func (jc *JetbrainsCommand) detectJetBrainsIDEs() error {
203203
// Set the full config directory path
204204
ide.ConfigDir = filepath.Join(configBasePath, dirName)
205205

206-
// Check for idea.properties file
207-
propertiesPath := filepath.Join(ide.ConfigDir, "idea.properties")
208-
if _, err := os.Stat(propertiesPath); err == nil {
209-
ide.PropertiesPath = propertiesPath
210-
} else {
211-
// Create idea.properties if it doesn't exist
212-
ide.PropertiesPath = propertiesPath
213-
}
206+
// Set idea.properties file path
207+
ide.PropertiesPath = filepath.Join(ide.ConfigDir, "idea.properties")
214208

215209
jc.detectedIDEs = append(jc.detectedIDEs, *ide)
216210
}

general/ide/vscode/vscode.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -543,13 +543,14 @@ func (vic *VscodeInstallCommand) downloadAndInstallExtension(repoURL string) err
543543
log.Info("Installing extension using VSCode CLI...")
544544

545545
// Install extension using VSCode's CLI
546-
var cmd *exec.Cmd
546+
var codeCmd string
547547
if runtime.GOOS == "windows" {
548-
cmd = exec.Command("code.cmd", "--install-extension", tempFile, "--force")
548+
codeCmd = "code.cmd"
549549
} else {
550-
cmd = exec.Command("code", "--install-extension", tempFile, "--force")
550+
codeCmd = "code"
551551
}
552552

553+
cmd := exec.Command(codeCmd, "--install-extension", tempFile, "--force")
553554
output, err := cmd.CombinedOutput()
554555
if err != nil {
555556
return fmt.Errorf("failed to install extension via VSCode CLI: %w\nOutput: %s", err, string(output))

0 commit comments

Comments
 (0)