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

Fix ./bin/importmap update #262

Merged
merged 1 commit into from
Sep 16, 2024
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
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
Loading