From 7a1499e0a3683f9d51dc18d73d8b087685a9e318 Mon Sep 17 00:00:00 2001 From: scribu Date: Sat, 26 Oct 2013 00:39:57 +0300 Subject: [PATCH] set default global config path; also, ignore if config file doesn't exist see #698 --- php/WP_CLI/Runner.php | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/php/WP_CLI/Runner.php b/php/WP_CLI/Runner.php index 42a943da..2e59a706 100644 --- a/php/WP_CLI/Runner.php +++ b/php/WP_CLI/Runner.php @@ -37,6 +37,22 @@ class Runner { } } + private static function get_global_config_path() { + $config_path = getenv( 'WP_CLI_CONFIG_PATH' ); + if ( isset( $runtime_config['config'] ) ) { + $config_path = $runtime_config['config']; + } + + if ( !$config_path ) { + $config_path = getenv( 'HOME' ) . '/.config/wp-cli.yml'; + } + + if ( !is_readable( $config_path ) ) + return false; + + return $config_path; + } + private static function get_project_config_path() { $config_files = array( 'wp-cli.local.yml', @@ -364,11 +380,7 @@ class Runner { list( $this->arguments, $this->assoc_args ) = self::back_compat_conversions( $args, $assoc_args ); - $this->global_config_path = getenv( 'WP_CLI_CONFIG_PATH' ); - if ( isset( $runtime_config['config'] ) ) { - $this->global_config_path = $runtime_config['config']; - } - + $this->global_config_path = self::get_global_config_path(); $this->project_config_path = self::get_project_config_path(); $configurator = \WP_CLI::get_configurator(); -- 2.11.0