Skip to content

Commit

Permalink
fix: set process working dir based on relative path of -f file too
Browse files Browse the repository at this point in the history
Why
===
* extends now sets the working dir of the processes in it based on the
relative path of the process-compose file.
* The documentation says that -f should be equvalent to using extends
* However, -f does not set the workign dir of the process to match the
process-compose file's path
* To make the documentation consistent again, we should also set the
working dir for the -f filename case.

What changed
===
* Move the working dir copy from loadExtendProject to
loadProjectFromFile

Test plan
===
* -f and extends both set the expected working dir of the processes in
my local tests
  • Loading branch information
ryantm committed Jan 9, 2025
1 parent 9d9e730 commit 8b0f635
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/loader/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ func loadExtendProject(p *types.Project, opts *LoaderOptions, file string, index
log.Error().Err(err).Msgf("Failed to load the extend project %s", p.ExtendsProject)
return fmt.Errorf("failed to load extend project %s: %w", p.ExtendsProject, err)
}
copyWorkingDirToProcesses(project, filepath.Dir(p.ExtendsProject))
opts.projects = slices.Insert(opts.projects, index, project)
err = loadExtendProject(project, opts, p.ExtendsProject, index)
if err != nil {
Expand Down Expand Up @@ -161,6 +160,7 @@ func loadProjectFromFile(inputFile string, opts *LoaderOptions) (*types.Project,
}
}

copyWorkingDirToProcesses(project, filepath.Dir(inputFile))
log.Info().Msgf("Loaded project from %s", inputFile)
return project, nil
}
Expand Down
4 changes: 2 additions & 2 deletions src/loader/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ func TestLoadFileWithExtendProject(t *testing.T) {
}
}
for _, proc := range opts.projects[1].Processes {
if proc.WorkingDir != "" {
t.Errorf("expected empty, got %s", proc.WorkingDir)
if proc.WorkingDir != expected {
t.Errorf("expected %s, got %s", expected, proc.WorkingDir)
}
}
}

0 comments on commit 8b0f635

Please sign in to comment.