Skip to content

Commit cc7142e

Browse files
authored
Fix ./bin/importmap update (#262)
1 parent 8a7d61c commit cc7142e

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/importmap/commands.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def outdated
9292
desc "update", "Update outdated package pins"
9393
def update
9494
if (outdated_packages = npm.outdated_packages).any?
95-
pin outdated_packages.map(&:name)
95+
pin(*outdated_packages.map(&:name))
9696
else
9797
puts "No outdated packages found"
9898
end

test/commands_test.rb

+16
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,22 @@ class CommandsTest < ActiveSupport::TestCase
2020
assert_includes JSON.parse(out), "imports"
2121
end
2222

23+
test "update command prints message of no outdated packages" do
24+
out, _err = run_importmap_command("update")
25+
assert_includes out, "No outdated"
26+
end
27+
28+
test "update command prints confirmation of pin with outdated packages" do
29+
@tmpdir = Dir.mktmpdir
30+
FileUtils.cp_r("#{__dir__}/dummy", @tmpdir)
31+
Dir.chdir("#{@tmpdir}/dummy")
32+
FileUtils.cp("#{__dir__}/fixtures/files/outdated_import_map.rb", "#{@tmpdir}/dummy/config/importmap.rb")
33+
FileUtils.cp("#{__dir__}/../lib/install/bin/importmap", "bin")
34+
35+
out, _err = run_importmap_command("update")
36+
assert_includes out, "Pinning"
37+
end
38+
2339
private
2440
def run_importmap_command(command, *args)
2541
capture_subprocess_io { system("bin/importmap", command, *args, exception: true) }

0 commit comments

Comments
 (0)