mikemadison13 / blt-lando

10 stars 9 forks source link

Plugin Shouldn't Overwrite Existing Files #8

Open greggmarshall opened 3 years ago

greggmarshall commented 3 years ago

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 commented 3 years ago

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

greggmarshall commented 3 years ago

That was FAST!

cballenar commented 2 years ago

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 commented 2 years ago

i'll have a look when i can