-
Notifications
You must be signed in to change notification settings - Fork 435
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
Move composer dependency to dev #556
Move composer dependency to dev #556
Conversation
HI @Landerstraeten, This won't do:
It is possible to remove the composer/composer dependency if we rewrite the 3 items mentioned above. It can be done by just manually parsing the root composer.json file of the project instead of relying on the composer loader / factory. |
f0588da
to
cd8f9ee
Compare
cd8f9ee
to
35c2d72
Compare
src/Console/Application.php
Outdated
$configuration = null; | ||
$rootPackage = null; | ||
} | ||
$composerFileLocation = getcwd().DIRECTORY_SEPARATOR.'composer.json'; |
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.
Is this path always guaranteed correct?
if it can't find the composer.json file, grumphp will crash on file_get_contents
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.
No it is not always available. probably better to detect composer.json from current directory and from all parents until one is found?
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.
There is a check in ComposerFile.php on line 21
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.
In the old codebase, there was a catch which returns an empty composer info.
Maybe it's best to catch the error from ComposerFile line 21 and also return an empty Composer instance?
That way, the code keeps on working if there is no composer.json in the cwd (which probably will happen more then once... ;) )
2f71095
to
c2e2473
Compare
src/Util/ComposerFile.php
Outdated
*/ | ||
public function getConfigDefaultPath() | ||
{ | ||
return null; |
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.
Shouldn't you check and return following param?
$extra['grumphp']['config-default-path'];
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.
Ow yes. Clearly something I forgot todo.
src/Console/Application.php
Outdated
$configuration = null; | ||
$rootPackage = null; | ||
} | ||
$composerFileLocation = getcwd().DIRECTORY_SEPARATOR.'composer.json'; |
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.
No it is not always available. probably better to detect composer.json from current directory and from all parents until one is found?
c2e2473
to
df9ab0f
Compare
df9ab0f
to
915823b
Compare
9e84839
to
e54ad42
Compare
1318b0f
to
4a45a25
Compare
src/Locator/ConfigurationFile.php
Outdated
|
||
return $this->locateConfigFileWithDistSupport($composerDefaultPath); | ||
return null === $composerDefaultPath |
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.
Maybe a bit more readable if shorter:
return $this->locateConfigFileWithDistSupport($composerDefaultPath ?: $defaultPath);
src/Console/Application.php
Outdated
$configuration = null; | ||
$rootPackage = null; | ||
} | ||
$composerFileLocation = getcwd().DIRECTORY_SEPARATOR.'composer.json'; |
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.
In the old codebase, there was a catch which returns an empty composer info.
Maybe it's best to catch the error from ComposerFile line 21 and also return an empty Composer instance?
That way, the code keeps on working if there is no composer.json in the cwd (which probably will happen more then once... ;) )
} | ||
|
||
return $config->get('bin-dir', Config::RELATIVE_PATHS); | ||
return $this->composer()->getComposerFile()->getBinDir(); |
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.
Maybe also safer to force a relative path as in the old codebase? Not sure too what folder the old code is making the path relative
4a45a25
to
6e8430b
Compare
@Landerstraeten : Can you tell me what the state of this PR is? I'dd love to get this one merged in. |
6e8430b
to
677eda2
Compare
No description provided.