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

Plugin Shouldn't Overwrite Existing Files #8

Open
greggmarshall opened this issue Feb 17, 2021 · 4 comments
Open

Plugin Shouldn't Overwrite Existing Files #8

greggmarshall opened this issue Feb 17, 2021 · 4 comments

Comments

@greggmarshall
Copy link
Contributor

When you execute blt recipes:vm:lando, the following files are copied from the plugin:
.lando.yml
README.md
blt/example.local.blt.yml
blt/local.blt.yml

If those files already exist, they are overwritten by the plugin.

Our carefully edited project README.md, which was setup when we initialized BLT and we have been maintaining ever since, was overwritten by the command (thank goodness for Git to restore it).

And, once I had updated and commited the .lando.yml file, when we tried the result on another developer's machine, the .lando.yml was reverted back to the plugin default.

This could be avoided by changing the 3rd argument to the copy method on lines 28, 39, 61 and 62 from TRUE (force the copy) to FALSE.

Also if you happen to execute blt recipes:vm:lando twice, the /sites/default/settings/local.settings.php file ends up with database credentials of drupal99. The first execution uses blt:init:settings to create the file, then does a replace in file on line 88 to change the default credentials of drupal to drupal9. The second execution doesn't force the copy during blt:init:settings so the replace in file changes the drupal9 to drupal99.

@mikemadison13
Copy link
Owner

thanks for these! i'll have a look and see what i can do.

greggmarshall added a commit to greggmarshall/blt-lando that referenced this issue Feb 17, 2021
mikemadison13 added a commit that referenced this issue Feb 17, 2021
Issue #8, don't overwrite existing files.
@greggmarshall
Copy link
Contributor Author

That was FAST!

@cballenar
Copy link

Requesting this issue be reopened.

Executing the command recipes:vm:lando results in the overwrite of existing files (README.md was also affected in my case). The correction made to address this issue does not seem to have fixed it.

If the copy() function in use is PHP's default copy (php.net/manual/en/function.copy.php), then I don't think there's a way to prevent overwrite via parameters and we just gotta go with the check below for each instance (or do a wrapper).

if(!is_file($dest_file)){
    copy($source_file, $dest_file);
}

Thoughts?

@mikemadison13 mikemadison13 reopened this Dec 9, 2021
@mikemadison13
Copy link
Owner

i'll have a look when i can

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

3 participants