From df25e54ef7a5568a51dd0cabdab942cf1ba36280 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Wed, 30 Jun 2021 10:20:22 +0100 Subject: [PATCH] chore(sign): simplify *.eln locating logic Instead of only checking very specific paths within the .app bundle, just check the whole bundle for any and all *.eln files. --- pkg/sign/emacs.go | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/pkg/sign/emacs.go b/pkg/sign/emacs.go index a5e0398..05a3f25 100644 --- a/pkg/sign/emacs.go +++ b/pkg/sign/emacs.go @@ -119,40 +119,18 @@ func signCLIHelper(ctx context.Context, appBundle string, opts *Options) error { // elnFiles finds all native-compilation *.eln files within a Emacs.app bundle, // based on expected paths they might be stored in. func elnFiles(emacsApp string) ([]string, error) { - dirs := []string{ - // Current *.eln location. - filepath.Join(emacsApp, "Contents", "Resources", "native-lisp"), - // Legacy *.eln location. - filepath.Join(emacsApp, "Contents", "MacOS", "lib", "emacs"), - } - var files []string - walkDirFunc := func(path string, _d fs.DirEntry, _err error) error { - if strings.HasSuffix(path, ".eln") { + walkDirFunc := func(path string, d fs.DirEntry, _err error) error { + if d.Type().IsRegular() && strings.HasSuffix(path, ".eln") { files = append(files, path) } return nil } - for _, dir := range dirs { - fi, err := os.Stat(dir) - if err != nil { - if os.IsNotExist(err) { - continue - } - - return nil, err - } - - if !fi.IsDir() { - continue - } - - err = filepath.WalkDir(dir, walkDirFunc) - if err != nil { - return nil, err - } + err := filepath.WalkDir(filepath.Join(emacsApp, "Contents"), walkDirFunc) + if err != nil { + return nil, err } return files, nil