Skip to content

Commit

Permalink
fix: Respect .chezmoiroot in source-path command with no arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Sep 23, 2022
1 parent ab36549 commit 9dda54a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/cmd/sourcepathcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ func (c *Config) newSourcePathCmd() *cobra.Command {

func (c *Config) runSourcePathCmd(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
return c.writeOutputString(c.SourceDirAbsPath.String() + "\n")
sourceDirAbsPath, err := c.sourceDirAbsPath()
if err != nil {
return err
}
return c.writeOutputString(sourceDirAbsPath.String() + "\n")
}

sourceState, err := c.newSourceState(cmd.Context())
Expand Down
6 changes: 6 additions & 0 deletions pkg/cmd/testdata/scripts/issue2380.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# test that chezmoi source-path with no arguments respects .chezmoiroot
exec chezmoi source-path
stdout ${CHEZMOISOURCEDIR@R}/home

-- home/user/.local/share/chezmoi/.chezmoiroot --
home

0 comments on commit 9dda54a

Please sign in to comment.