Closed esolitos closed 6 years ago
I see, that's indeed a problem. I just had a look into Composer. Unfortunately the composer.json fallback is not encapsulated, so that we cannot easily use a public method.
But it's basically following code, that is handling it. It can be integrated as an initializing method.
$dir = dirname(getcwd());
$home = realpath(getenv('HOME') ?: getenv('USERPROFILE') ?: '/');
// abort when we reach the home dir or top of the filesystem
while (dirname($dir) !== $dir && $dir !== $home) {
if (file_exists($dir.'/'.Factory::getComposerFile())) {
if ($io->askConfirmation('<info>No composer.json in current directory, do you want to use the one at '.$dir.'?</info> [<comment>Y,n</comment>]? ', true)) {
$oldWorkingDir = getcwd();
chdir($dir);
}
break;
}
$dir = dirname($dir);
}
(Sorry for initial empty issue) Since version 1.5 composer can handle running in subdirectories, prompting the user with a ,essage like:
I believe this plugin should use the same approach. As of now if run in a subdirectory an error is returned: