Skip to content

Commit 31b0f16

Browse files
committed
Ensure update only runs when there are outdated packages
1 parent 61727c4 commit 31b0f16

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Diff for: lib/importmap/commands.rb

+6-4
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,7 @@ def audit
7575

7676
desc "outdated", "Check for outdated packages"
7777
def outdated
78-
outdated_packages = npm.outdated_packages
79-
80-
if outdated_packages.any?
78+
if (outdated_packages = npm.outdated_packages).any?
8179
table = [["Package", "Current", "Latest"]]
8280
outdated_packages.each { |p| table << [p.name, p.current_version, p.latest_version || p.error] }
8381

@@ -93,7 +91,11 @@ def outdated
9391

9492
desc "update", "Update outdated package pins"
9593
def update
96-
pin npm.outdated_packages.map(&:name)
94+
if (outdated_packages = npm.outdated_packages).any?
95+
pin outdated_packages.map(&:name)
96+
else
97+
puts "No outdated packages found"
98+
end
9799
end
98100

99101
desc "packages", "Print out packages with version numbers"

0 commit comments

Comments
 (0)