Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When installed from git/vcs, original folder not deleted #22

Open
Youdaman opened this issue May 5, 2021 · 2 comments
Open

When installed from git/vcs, original folder not deleted #22

Youdaman opened this issue May 5, 2021 · 2 comments

Comments

@Youdaman
Copy link

Youdaman commented May 5, 2021

Hi, I have a repo setup using SatisPress where I have a custom plugin that has the following file structure:

foo/

  • foo.php
  • composer.json
  • .gitignore
  • .git/

If I setup my website's composer.json with the following:

   "dropin-paths": {
      "wp-content/mu-plugins/": ["type:wordpress-muplugin", "package:repo/foo:foo.php"]
    },

Then it installs the plugin as an muplugin correctly, i.e. it ends up having only wp-content/mu-plugins/foo.php

However if I set it up using git instead:

"repositories": [
   {
      "type": "vcs",
      "url": "https://[email protected]/baz/foo.git"
    }
]

and

   "dropin-paths": {
      "wp-content/mu-plugins/": ["type:wordpress-muplugin", "package:baz/foo:foo.php"]
    },

When it installs it leaves behind the original directory, i.e. wp-content/mu-plugins/foo.php along with wp-content/mu-plugins/foo/ (and in that directory is the composer.json, .git/ and .gitignore).

So in summary, pulling from a repo works as expected, moving the specified file and deleting the original directory, but pulling from vcs/git does not delete the original directory after the move.

@Youdaman
Copy link
Author

Youdaman commented May 5, 2021

Actually, I just noticed that if I do things using the repo method instead of vcs, it initially puts the plugin in wp-content/plugins/foo/foo.php and then just moves foo.php to wp-content/mu-plugins/foo.php and leaves behind the original directory in wp-content/plugins/foo/

The difference between the repo vs vcs methods then becomes that the repo method has an empty folder left behind while the vcs method has the composer.json and .git/ and .gitignore, so I guess that's just because the repo method doesn't fetch/install these files.

So it looks like the behaviour is probably working as expected and I need to work out whether I want to delete the original directories somehow.

I did spot the following in Dropin.php so I guess that was an idea you had already:

   #We could Remove original directories but don't do it
    #unlink($src);

@onnimonni
Copy link
Member

If you add an opt-in option for the delete and document it in readme and add unit test for it I'm willing to merge it 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants