Class: Dependabot::NpmAndYarn::FileUpdater

Inherits:
FileUpdaters::Base
  • Object
show all
Defined in:
lib/dependabot/npm_and_yarn/file_updater.rb,
lib/dependabot/npm_and_yarn/file_updater/npmrc_builder.rb,
lib/dependabot/npm_and_yarn/file_updater/npm_lockfile_updater.rb,
lib/dependabot/npm_and_yarn/file_updater/package_json_updater.rb,
lib/dependabot/npm_and_yarn/file_updater/package_json_preparer.rb,
lib/dependabot/npm_and_yarn/file_updater/yarn_lockfile_updater.rb

Defined Under Namespace

Classes: NoChangeError, NpmLockfileUpdater, NpmrcBuilder, PackageJsonPreparer, PackageJsonUpdater, YarnLockfileUpdater

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.updated_files_regexObject



26
27
28
29
30
31
32
33
# File 'lib/dependabot/npm_and_yarn/file_updater.rb', line 26

def self.updated_files_regex
  [
    /^package\.json$/,
    /^package-lock\.json$/,
    /^npm-shrinkwrap\.json$/,
    /^yarn\.lock$/
  ]
end

Instance Method Details

#updated_dependency_filesObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/dependabot/npm_and_yarn/file_updater.rb', line 35

def updated_dependency_files
  updated_files = []

  updated_files += updated_manifest_files
  updated_files += updated_lockfiles

  if updated_files.none?
    raise NoChangeError.new(
      message: "No files were updated!",
      error_context: error_context(updated_files: updated_files)
    )
  end

  sorted_updated_files = updated_files.sort_by(&:name)
  if sorted_updated_files == filtered_dependency_files.sort_by(&:name)
    raise NoChangeError.new(
      message: "Updated files are unchanged!",
      error_context: error_context(updated_files: updated_files)
    )
  end

  updated_files
end