Skip to content

Commit

Permalink
Protect vendor/bin path entry in uninstalls
Browse files Browse the repository at this point in the history
  • Loading branch information
johnstevenson committed Aug 3, 2017
1 parent 0f5bd33 commit ef5ded4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,6 +1,7 @@
## v4.7.0
Not yet released

* Stopped uninstall removing `Composer\vendor\bin` from the user path if there is another composer files directory in the path (ie from a subseqent Devloper mode installation).
* Improved shell proxy handling, in case of `CDPATH` conflicts.
* Improved error reporting, making use of stderr now that PHP uses it better.
* Added output from stdout and stderr to the log file for better troubleshooting.
Expand Down
25 changes: 21 additions & 4 deletions src/composer.iss
Expand Up @@ -870,6 +870,9 @@ end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
BinPath: String;
BinDir: String;
NoBin: Boolean;
Home: String;
Cache: String;
Error: String;
Expand All @@ -883,12 +886,26 @@ begin
deleted. Also we need to know if the user data folders still exist}
UserDataDelete();
{Remove composer from path}
PathChange(GetRegHive(), ENV_REMOVE, GetBinDir(''), False);
{Remove composer from the bin path if it matches the default location,
which will not be the case if a Developer mode install has been made over
the top of this one}
SetPathInfo(True);
BinPath := Paths.Bin.Data.Path;
BinDir := GetBinDir('');
if CompareText(BinDir, BinPath) = 0 then
begin
PathChange(GetRegHive(), ENV_REMOVE, BinDir, False);
NoBin := True;
end
else
NoBin := BinPath = '';
if not IsSystemUser() then
{Only remove vendor/bin from the user path if composer is no longer in the
path and the user data folders do not exist}
if NoBin and not IsSystemUser() then
begin
{Only remove vendor/bin from path if the data folders were deleted}
Home := ExpandConstant('{userappdata}\Composer');
Cache := ExpandConstant('{localappdata}\Composer');
Expand Down

0 comments on commit ef5ded4

Please sign in to comment.