plugins: load directories that are symlinks (#2214)

Fix issue where symlinked plugin directories were ignored. For example

    $ file ~/.config/micro/plug/example
    example: symbolic link to <target directory>

This allows plugins to be managed in a user's "dotfiles" repository, and
be symlinked into micro's plugin directory.
This commit is contained in:
Daniel Lee Harple 2022-07-24 17:13:46 -04:00 committed by GitHub
parent 208a778387
commit 88e76b367c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -186,8 +186,9 @@ func InitRuntimeFiles() {
isID := regexp.MustCompile(`^[_A-Za-z0-9]+$`).MatchString isID := regexp.MustCompile(`^[_A-Za-z0-9]+$`).MatchString
for _, d := range files { for _, d := range files {
if d.IsDir() { plugpath := filepath.Join(plugdir, d.Name())
srcs, _ := ioutil.ReadDir(filepath.Join(plugdir, d.Name())) if stat, err := os.Stat(plugpath); err == nil && stat.IsDir() {
srcs, _ := ioutil.ReadDir(plugpath)
p := new(Plugin) p := new(Plugin)
p.Name = d.Name() p.Name = d.Name()
p.DirName = d.Name() p.DirName = d.Name()