summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2020-05-19 12:07:27 -0600
committermo khan <mo.khan@gmail.com>2020-05-19 12:07:27 -0600
commitee7b5af4bd860f373cb3744329152f9c837f3cd1 (patch)
tree89ee8f3d567f38eab25d676034c9cabea02a1b63
parent0f1db0d60c61a6db1c5389fc0ddb2d984789b330 (diff)
Collect dependencies of dependencies in bower project
-rw-r--r--lib/license/finder/ext/bower.rb18
-rw-r--r--spec/integration/js/bower_spec.rb7
2 files changed, 16 insertions, 9 deletions
diff --git a/lib/license/finder/ext/bower.rb b/lib/license/finder/ext/bower.rb
index 3c6ba6f..53d5f5e 100644
--- a/lib/license/finder/ext/bower.rb
+++ b/lib/license/finder/ext/bower.rb
@@ -8,8 +8,8 @@ module LicenseFinder
def current_packages
bower_output.map do |bower_module|
- map_from(bower_module)
- end
+ map_all(bower_module)
+ end.flatten
end
def possible_package_paths
@@ -28,28 +28,30 @@ module LicenseFinder
json.fetch('dependencies', {}).values
end
- def map_from(bower_module)
+ def map_all(bower_module)
+ items = []
spec = bower_module.fetch('pkgMeta', {})
if spec.empty?
endpoint = bower_module.fetch('endpoint', {})
- Package.new(
+ items << Package.new(
endpoint['name'],
endpoint['target'],
- install_path: bower_module['canonicalDir'],
+ install_path: bower_module['canonicalDir']
)
else
- Package.new(
+ items << Package.new(
spec['name'],
spec['version'],
summary: spec['description'],
description: spec['readme'],
homepage: spec['homepage'],
spec_licenses: Package.license_names_from_standard_spec(spec),
- install_path: bower_module['canonicalDir'],
+ install_path: bower_module['canonicalDir']
)
end
+
+ items + bower_module.fetch('dependencies', {}).values.map { |x| map_all(x) }
end
end
end
-
diff --git a/spec/integration/js/bower_spec.rb b/spec/integration/js/bower_spec.rb
index b72f256..1f97645 100644
--- a/spec/integration/js/bower_spec.rb
+++ b/spec/integration/js/bower_spec.rb
@@ -9,10 +9,15 @@ RSpec.describe "bower" do
end
specify { expect(subject).to match_schema(version: '2.0') }
- specify { expect(subject.dependency_names).to match_array(['cli', 'jquery', 'masonry-layout', 'stimulus.umd']) }
+ specify { expect(subject.dependency_names).to match_array(['cli', 'ev-emitter', 'fizzy-ui-utils', 'get-size', 'jquery', 'masonry-layout', 'matches-selector', 'outlayer', 'stimulus.umd']) }
specify { expect(subject.licenses_for('cli')).to match_array(['Apache-2.0', 'BSD-3-Clause', 'ISC', 'MIT']) }
+ specify { expect(subject.licenses_for('ev-emitter')).to match_array(['MIT']) }
+ specify { expect(subject.licenses_for('fizzy-ui-utils')).to match_array(['MIT']) }
+ specify { expect(subject.licenses_for('get-size')).to match_array(['MIT']) }
specify { expect(subject.licenses_for('jquery')).to match_array(['MIT']) }
specify { expect(subject.licenses_for('masonry-layout')).to match_array(['MIT']) }
+ specify { expect(subject.licenses_for('matches-selector')).to match_array(['MIT']) }
+ specify { expect(subject.licenses_for('outlayer')).to match_array(['MIT']) }
specify { expect(subject.licenses_for('stimulus.umd')).to match_array(['unknown']) }
end
end