Skip to content

Commit

Permalink
update detected paths for Nuget
Browse files Browse the repository at this point in the history
[#155410833]

Signed-off-by: Vikram Yadav <vyadav@pivotal.io>
  • Loading branch information
Vikram Yadav authored and xtreme-shane-lattanzio committed Mar 21, 2018
1 parent d6702cf commit 3fe8995
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
3 changes: 2 additions & 1 deletion lib/license_finder/package_managers/nuget.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def dependencies
def possible_package_paths
path = project_path.join('vendor/*.nupkg')
nuget_dir = Dir[path].map { |pkg| File.dirname(pkg) }.uniq
possible_paths = [project_path.join('.nuget'), project_path.join('packages')]

possible_paths = [project_path.join('packages.config'), project_path.join('.nuget')]
possible_paths.unshift(Pathname(nuget_dir.first)) unless nuget_dir.empty?
possible_paths
end
Expand Down
File renamed without changes.
20 changes: 16 additions & 4 deletions spec/lib/license_finder/package_managers/nuget_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,26 @@ def self.broken_fakefs?
end
end

context 'when vendor and .nuget are not present but a packages directory exists' do
context 'when .nuget exists' do
before do
FileUtils.mkdir_p 'app/packages'
FileUtils.mkdir_p 'app/.nuget'
end

it 'returns the packages.config file path' do
nuget = Nuget.new project_path: Pathname.new('app')
expect(nuget.detected_package_path).to eq Pathname('app/.nuget')
end
end

context 'when vendor/*.nupkg and .nuget/ are not present but packages.config file exists' do
before do
FileUtils.mkdir_p 'app'
FileUtils.touch 'app/packages.config'
end

it 'returns the packages directory' do
it 'returns the packages.config file' do
nuget = Nuget.new project_path: Pathname.new('app')
expect(nuget.detected_package_path).to eq Pathname('app/packages')
expect(nuget.detected_package_path).to eq Pathname('app/packages.config')
end
end
end
Expand Down
1 change: 1 addition & 0 deletions spec/support/shared_examples_for_package_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module LicenseFinder

it { expect(described_class.ancestors).to include PackageManager }
it { expect(Scanner::PACKAGE_MANAGERS).to include described_class }

describe '.active?' do
before do
allow_any_instance_of(described_class).to receive(:go_files_exist?).and_return(true)
Expand Down

0 comments on commit 3fe8995

Please sign in to comment.