From b6d12f9cbd32004d5553fa3be863958393c260f1 Mon Sep 17 00:00:00 2001 From: Michael Karlesky Date: Thu, 29 Aug 2024 09:33:46 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Log=20full=20project=20filepath=20+?= =?UTF-8?q?=20working=20dir?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Github issue #918 --- bin/projectinator.rb | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/bin/projectinator.rb b/bin/projectinator.rb index 62412efd..35f74b9b 100644 --- a/bin/projectinator.rb +++ b/bin/projectinator.rb @@ -26,25 +26,28 @@ class Projectinator def load(filepath:nil, env:{}, silent:false) # Highest priority: command line argument if filepath - config = load_filepath( filepath, 'from command line argument', silent ) - return File.expand_path( filepath ), config + _filepath = File.expand_path( filepath ) + config = load_and_log( _filepath, 'from command line argument', silent ) + return _filepath, config # Next priority: environment variable elsif env[PROJECT_FILEPATH_ENV_VAR] filepath = env[PROJECT_FILEPATH_ENV_VAR] + _filepath = File.expand_path( filepath ) @path_validator.standardize_paths( filepath ) - config = load_filepath( - filepath, + config = load_and_log( + _filepath, "from environment variable `#{PROJECT_FILEPATH_ENV_VAR}`", silent ) - return File.expand_path( filepath ), config + return _filepath, config # Final option: default filepath elsif @file_wrapper.exist?( DEFAULT_PROJECT_FILEPATH ) filepath = DEFAULT_PROJECT_FILEPATH - config = load_filepath( filepath, "at default location", silent ) - return File.expand_path( filepath ), config + _filepath = File.expand_path( filepath ) + config = load_and_log( _filepath, "from working directory", silent ) + return _filepath, config # If no user provided filepath and the default filepath does not exist, # we have a big problem @@ -205,7 +208,7 @@ def lookup_mixins(mixins:, load_paths:, builtins:, yaml_extension:) private - def load_filepath(filepath, method, silent) + def load_and_log(filepath, method, silent) begin # Load the filepath we settled on as our project configuration config = @yaml_wrapper.load( filepath ) @@ -216,7 +219,10 @@ def load_filepath(filepath, method, silent) # Log what the heck we loaded if !silent - msg = "Loaded #{'(empty) ' if config.empty?}project configuration #{method} using #{filepath}" + msg = "Loaded #{'(empty) ' if config.empty?}project configuration #{method}.\n" + msg += " > Using: #{filepath}\n" + msg += " > Working directory: #{Dir.pwd()}" + @loginator.log( msg, Verbosity::NORMAL, LogLabels::CONSTRUCT ) end