Skip to content

Commit

Permalink
[Fixed] log path issues
Browse files Browse the repository at this point in the history
Signed-off-by: Shane Lattanzio <slattanzio@pivotal.io>
  • Loading branch information
Daniil Kouznetsov authored and xtreme-shane-lattanzio committed Jan 22, 2018
1 parent 79080ad commit 9f1bae1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
7 changes: 6 additions & 1 deletion lib/license_finder/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/license_finder/license_aggregator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 25 additions & 2 deletions spec/lib/license_finder/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 9f1bae1

Please sign in to comment.