Skip to content

Commit

Permalink
Fix path issue
Browse files Browse the repository at this point in the history
  • Loading branch information
sfowl committed Nov 13, 2023
1 parent dff8928 commit 8228b5d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions internal/scan/ruby.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func GetRubyDeps(path string) (map[string]string, error) {

if gemspec != "" {
log.Debugf("Found %s, parsing", gemspec)
return runRubyParser(gemSpecParser, gemspec)
return runRubyParser(gemSpecParser, gemspec, baseDir)
}

lockPath := filepath.Join(baseDir, "Gemfile.lock")
Expand All @@ -66,18 +66,19 @@ func GetRubyDeps(path string) (map[string]string, error) {
cmd := exec.CommandContext(ctx, "env", fmt.Sprintf("--chdir=%s", baseDir), "bundle", "lock")
data, err := cmd.CombinedOutput()
if err != nil {
log.Errorf("couldn't create %s: %v", lockPath, err)
log.Debugf("couldn't create %s: %v", lockPath, err)
log.Debugf("bundle lock output: %v", string(data))
}
log.Debugf("Created %s", lockPath)
} else {
log.Errorf("Unexpected error: %v", err)
return nil, err
}
}
return runRubyParser(gemFileParser, baseDir)
return runRubyParser(gemFileParser, ".", baseDir)
}

func runRubyParser(script Script, target string) (map[string]string, error) {
func runRubyParser(script Script, arg string, dir string) (map[string]string, error) {
gathered := make(map[string]string)

g, err := os.CreateTemp("", script.Name)
Expand All @@ -91,9 +92,8 @@ func runRubyParser(script Script, target string) (map[string]string, error) {
log.Errorf("Could not write ruby script to %s: %s", g.Name(), err)
return gathered, err
}
dir := filepath.Dir(target)
name := filepath.Base(target)
args := []string{fmt.Sprintf("--chdir=%s", dir), "ruby", g.Name(), name}

args := []string{fmt.Sprintf("--chdir=%s", dir), "ruby", g.Name(), arg}
log.Debugf("Running env %v", args)
cmd := exec.Command("env", args...)
data, err := cmd.Output()
Expand Down

0 comments on commit 8228b5d

Please sign in to comment.