diff --git a/lib/importmap/commands.rb b/lib/importmap/commands.rb index 350cc42..fc59e72 100644 --- a/lib/importmap/commands.rb +++ b/lib/importmap/commands.rb @@ -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 diff --git a/test/commands_test.rb b/test/commands_test.rb index 8a3155a..1efd210 100644 --- a/test/commands_test.rb +++ b/test/commands_test.rb @@ -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) }