diff --git a/lib/license_finder/configuration.rb b/lib/license_finder/configuration.rb index af8c61b5e..c50507c38 100644 --- a/lib/license_finder/configuration.rb +++ b/lib/license_finder/configuration.rb @@ -46,7 +46,12 @@ def decisions_file_path def log_directory path = get(:log_directory) || 'lf_logs' - project_path.join(path).expand_path + + if (aggregate_paths || recursive) && project_path == '' + Pathname(path).expand_path + else + project_path.join(path).expand_path + end end def project_path diff --git a/lib/license_finder/license_aggregator.rb b/lib/license_finder/license_aggregator.rb index 3af41f471..8f9382104 100644 --- a/lib/license_finder/license_aggregator.rb +++ b/lib/license_finder/license_aggregator.rb @@ -34,6 +34,7 @@ def finders @aggregate_paths.map do |path| # Passing file paths as values instead of allowing them to evaluate in config LicenseFinder::Core.new(@config.merge(project_path: path, + log_directory: @config.log_directory || @config.project_path, decisions_file: @config.decisions_file_path)) end end diff --git a/spec/lib/license_finder/configuration_spec.rb b/spec/lib/license_finder/configuration_spec.rb index 8473c4255..4b7d21046 100644 --- a/spec/lib/license_finder/configuration_spec.rb +++ b/spec/lib/license_finder/configuration_spec.rb @@ -114,8 +114,31 @@ module LicenseFinder expect(subject.log_directory.to_s).to end_with 'lf_logs' end - it 'prepends project path to default path if project_path option is set' do - subject = described_class.new({ project_path: 'magic_path' }, {}) + it 'prepends project path to default path if project_path option is set and not recursive' do + subject = described_class.new( + { project_path: 'magic_path', + recursive: false, + aggregate_paths: false }, {} + ) + expect(subject.log_directory.to_s).to end_with 'magic_path/lf_logs' + end + + it 'prepends project path to default path if project_path option is not set and not recursive' do + subject = described_class.new( + { project_path: nil, + recursive: true, + aggregate_paths: true }, {} + ) + expect(subject.log_directory.to_s).to_not end_with 'magic_path/lf_logs' + expect(subject.log_directory.to_s).to end_with 'lf_logs' + end + + it 'prepends project path to default path if project_path option is set and not recursive' do + subject = described_class.new( + { project_path: 'magic_path', + recursive: true, + aggregate_paths: true }, {} + ) expect(subject.log_directory.to_s).to end_with 'magic_path/lf_logs' end