Skip to content

Commit

Permalink
Grab pkgname from interface collection
Browse files Browse the repository at this point in the history
  • Loading branch information
LandonTClipp committed Jan 3, 2025
1 parent 8e90c1e commit 6f043b6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/cmd/mockery.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ func (r *RootApp) Run() error {
interfacesInFile.outFilePath.Parent(),
packageConfig.Template,
pkg.Formatter(r.Config.Formatter),
packageConfig,
interfacesInFile.pkgName,
)
if err != nil {
return err
Expand Down
6 changes: 3 additions & 3 deletions internal/template_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,14 @@ func NewTemplateGenerator(
outPkgFSPath *pathlib.Path,
templateName string,
formatter Formatter,
pkgConfig *Config,
pkgName string,
) (*TemplateGenerator, error) {
srcPkgFSPath := pathlib.NewPath(srcPkg.GoFiles[0]).Parent()
log := zerolog.Ctx(ctx).With().
Stringer("srcPkgFSPath", srcPkgFSPath).
Stringer("outPkgFSPath", outPkgFSPath).
Str("src-pkg-name", srcPkg.Name).
Str("out-pkg-name", pkgConfig.PkgName).
Str("out-pkg-name", pkgName).
Logger()
if !outPkgFSPath.IsAbsolute() {
cwd, err := os.Getwd()
Expand All @@ -140,7 +140,7 @@ func NewTemplateGenerator(
// Note: Technically, go allows test files to have a different package name
// than non-test files. In this case, the test files have to import the source
// package just as if it were in a different directory.
if pkgConfig.PkgName == srcPkg.Name && srcPkgFSPath.Equals(outPkgFSPath) {
if pkgName == srcPkg.Name && srcPkgFSPath.Equals(outPkgFSPath) {
log.Debug().Msg("output package detected to be in-package of original package")
inPackage = true
} else {
Expand Down

0 comments on commit 6f043b6

Please sign in to comment.