-
Notifications
You must be signed in to change notification settings - Fork 24
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
Add logic to remove the project directory after 'cgr remove' #21
Conversation
src/Application.php
Outdated
* prior to completing the process of iterating through all the projects. | ||
*/ | ||
list(, $workingDir, $composerCommand, $orgProject) = explode(' ', $command->getCommandString()); | ||
if ($composerCommand == "'remove'") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be done in some other location, so that we do not need to decompose and parse the command string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. It would have to been done after the cgr remove
command has executed. Do you have a suggested location?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose you could add a public method to the CommandToExec class that returns a parsed array of the command arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Change
runCommandList()
so that it will run either function pointers or exec external tools. - Define a
removeCommand()
method, so that will be called instead ofgeneralCommand
for remove commands. - Make
removeCommand()
call through togeneralCommand()
and also return a function pointer to the extra cleanup you want to do.
Doing 1 implies a new base class for things to execute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds complicated. :) I'm not so sure calling through generalCommand()
will produce the intended results unless you mean encapsulating the entire run process? Remember, we can only remove the directory after the composer remove
command is executed. What do you think of just bypassing the composer remove
command altogether and just remove the directory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Completely replacing the composer remove
command would be a fine option.
$projectSpecificArgs = array("--working-dir=$installLocation", $composerCommand); | ||
if (!empty($projectWithVersion)) { | ||
$projectSpecificArgs[] = $projectWithVersion; | ||
if ($composerCommand == 'remove') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, but you don't need to add special-checking to buildGlobalCommand()
. If you define a method removeCommand()
, it will be called instead. You can then build and return whatever sort of CommandToExec()
you'd like.
Closing since #22 is a better way. |
No description provided.