Skip to content
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

Improve detection of home path. Also allow ~/.grav on Windows, drop ConsoleTrait::isWindows() method, used just for that. #1204

Merged
merged 6 commits into from
Dec 16, 2016

Conversation

flaviocopes
Copy link
Contributor

…onsoleTrait::isWindows() method, used just for that.
@c33s
Copy link

c33s commented Dec 11, 2016

i will test it on my windows machine asap.

$this->local_config = Yaml::parse($local_config_file);
$this->output->writeln('Read local config from <cyan>' . $local_config_file . '</cyan>');
}
$home_folder = getenv('HOME') ?: getenv('HOMEDRIVE') . getenv('HOMEPATH');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not put this (69-73 in this file) and line 116-119 from gmp into the console trait?

public function loadLocalConfig($cli=false) 
{
    $home_folder = getenv('HOME') ?: getenv('HOMEDRIVE') . getenv('HOMEPATH');
    $local_config_file = $home_folder . '/.grav/config';
    if (file_exists($local_config_file)) {
        $this->local_config = Yaml::parse($local_config_file);
        if ($cli) {
            $this->output->writeln('Read local config from <cyan>' . $local_config_file . '</cyan>');
        }
    }
}

calling it with $this->loadLocalConfig(true) or $this->loadLocalConfig(false)

or change the if ($cli) to:

if ($this->output && get_class($this->output)=='OutputInterface') 

and remove the $cli parameter from loadLocalConfig

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, I've extracted the method to ConsoleTrait as you suggested, with the change that it returns the local file path if found.

@flaviocopes flaviocopes merged commit 0ccc34d into develop Dec 16, 2016
@flaviocopes flaviocopes deleted the feature/improve-localconfig branch December 16, 2016 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants