Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor NpmLockfileUpdater #3112

Merged
merged 1 commit into from
Feb 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 9 additions & 19 deletions npm_and_yarn/lib/dependabot/npm_and_yarn/file_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ def yarn_lock_changed?(yarn_lock)
end

def package_lock_changed?(package_lock)
package_lock.content != updated_package_lock_content(package_lock)
package_lock.content != updated_lockfile_content(package_lock)
end

def shrinkwrap_changed?(shrinkwrap)
shrinkwrap.content != updated_package_lock_content(shrinkwrap)
shrinkwrap.content != updated_lockfile_content(shrinkwrap)
end

def updated_manifest_files
Expand Down Expand Up @@ -150,7 +150,7 @@ def updated_lockfiles

updated_files << updated_file(
file: package_lock,
content: updated_package_lock_content(package_lock)
content: updated_lockfile_content(package_lock)
)
end

Expand All @@ -159,7 +159,7 @@ def updated_lockfiles

updated_files << updated_file(
file: shrinkwrap,
content: updated_shrinkwrap_content(shrinkwrap)
content: updated_lockfile_content(shrinkwrap)
)
end

Expand All @@ -181,25 +181,15 @@ def yarn_lockfile_updater
)
end

def updated_package_lock_content(package_lock)
@updated_package_lock_content ||= {}
@updated_package_lock_content[package_lock.name] ||=
npm_lockfile_updater.updated_lockfile_content(package_lock)
end

def updated_shrinkwrap_content(shrinkwrap)
@updated_shrinkwrap_content ||= {}
@updated_shrinkwrap_content[shrinkwrap.name] ||=
npm_lockfile_updater.updated_lockfile_content(shrinkwrap)
end

def npm_lockfile_updater
@npm_lockfile_updater ||=
def updated_lockfile_content(file)
@updated_lockfile_content ||= {}
@updated_lockfile_content[file.name] ||=
NpmLockfileUpdater.new(
lockfile: file,
dependencies: dependencies,
dependency_files: dependency_files,
credentials: credentials
)
).updated_lockfile.content
end

def updated_package_json_content(file)
Expand Down
Loading