Class: Dependabot::NpmAndYarn::SubDependencyFilesFilterer

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/npm_and_yarn/sub_dependency_files_filterer.rb

Instance Method Summary collapse

Constructor Details

#initialize(dependency_files:, updated_dependencies:) ⇒ SubDependencyFilesFilterer

Returns a new instance of SubDependencyFilesFilterer.



19
20
21
22
# File 'lib/dependabot/npm_and_yarn/sub_dependency_files_filterer.rb', line 19

def initialize(dependency_files:, updated_dependencies:)
  @dependency_files = dependency_files
  @updated_dependencies = updated_dependencies
end

Instance Method Details

#files_requiring_updateObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/dependabot/npm_and_yarn/sub_dependency_files_filterer.rb', line 25

def files_requiring_update
  return T.must(@files_requiring_update) if defined? @files_requiring_update

  files_requiring_update =
    lockfiles.select do |lockfile|
      lockfile_dependencies(lockfile).any? do |sub_dep|
        updated_dependencies.any? do |updated_dep|
          next false unless sub_dep.name == updated_dep.name

          version_class.new(updated_dep.version) >
            version_class.new(sub_dep.version)
        end
      end
    end

  @files_requiring_update ||= T.let(files_requiring_update, T.nilable(T::Array[DependencyFile]))
end