Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.
Open
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
11 changes: 10 additions & 1 deletion pkg/modules/nuget/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,14 @@ var (
// Parse ...
func (c command) Parse() []string {
cmd := strings.TrimSpace(string(c))
return strings.Fields(cmd)

// Keep double-quoted strings as a single token
quoted := false
tokens := strings.FieldsFunc(cmd, func(r rune) bool {
if r == '"' {
quoted = !quoted
}
return !quoted && r == ' '
})
return tokens
}
3 changes: 2 additions & 1 deletion pkg/modules/nuget/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ func (m *nuget) HasModulesInstalled(path string) error {
projectPath := m.GetProjectManifestPath(path)
log.Infof("trying to restore the packages: %s", projectPath)

restoreCommand := command(fmt.Sprintf("%s %s", RestorePackageCmd, projectPath))
// Add double-quotes around projectPath to handle spaces in paths
restoreCommand := command(fmt.Sprintf("%s \"%s\"", RestorePackageCmd, projectPath))
if err := m.buildCmd(restoreCommand, "."); err != nil {
return err
}
Expand Down