Skip to content

Commit

Permalink
Fix ./bin/importmap update (#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
arni1981 authored Sep 16, 2024
1 parent 8a7d61c commit cc7142e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/importmap/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def outdated
desc "update", "Update outdated package pins"
def update
if (outdated_packages = npm.outdated_packages).any?
pin outdated_packages.map(&:name)
pin(*outdated_packages.map(&:name))
else
puts "No outdated packages found"
end
Expand Down
16 changes: 16 additions & 0 deletions test/commands_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,22 @@ class CommandsTest < ActiveSupport::TestCase
assert_includes JSON.parse(out), "imports"
end

test "update command prints message of no outdated packages" do
out, _err = run_importmap_command("update")
assert_includes out, "No outdated"
end

test "update command prints confirmation of pin with outdated packages" do
@tmpdir = Dir.mktmpdir
FileUtils.cp_r("#{__dir__}/dummy", @tmpdir)
Dir.chdir("#{@tmpdir}/dummy")
FileUtils.cp("#{__dir__}/fixtures/files/outdated_import_map.rb", "#{@tmpdir}/dummy/config/importmap.rb")
FileUtils.cp("#{__dir__}/../lib/install/bin/importmap", "bin")

out, _err = run_importmap_command("update")
assert_includes out, "Pinning"
end

private
def run_importmap_command(command, *args)
capture_subprocess_io { system("bin/importmap", command, *args, exception: true) }
Expand Down

0 comments on commit cc7142e

Please sign in to comment.