Skip to content

Commit 8b0f635

Browse files
committed
fix: set process working dir based on relative path of -f file too
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
1 parent 9d9e730 commit 8b0f635

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/loader/loader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ func loadExtendProject(p *types.Project, opts *LoaderOptions, file string, index
9393
log.Error().Err(err).Msgf("Failed to load the extend project %s", p.ExtendsProject)
9494
return fmt.Errorf("failed to load extend project %s: %w", p.ExtendsProject, err)
9595
}
96-
copyWorkingDirToProcesses(project, filepath.Dir(p.ExtendsProject))
9796
opts.projects = slices.Insert(opts.projects, index, project)
9897
err = loadExtendProject(project, opts, p.ExtendsProject, index)
9998
if err != nil {
@@ -161,6 +160,7 @@ func loadProjectFromFile(inputFile string, opts *LoaderOptions) (*types.Project,
161160
}
162161
}
163162

163+
copyWorkingDirToProcesses(project, filepath.Dir(inputFile))
164164
log.Info().Msgf("Loaded project from %s", inputFile)
165165
return project, nil
166166
}

src/loader/loader_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ func TestLoadFileWithExtendProject(t *testing.T) {
177177
}
178178
}
179179
for _, proc := range opts.projects[1].Processes {
180-
if proc.WorkingDir != "" {
181-
t.Errorf("expected empty, got %s", proc.WorkingDir)
180+
if proc.WorkingDir != expected {
181+
t.Errorf("expected %s, got %s", expected, proc.WorkingDir)
182182
}
183183
}
184184
}

0 commit comments

Comments
 (0)