Skip to content

Confusion between the :to and :under options of pin_all_from #67

Closed
@radiantshaw

Description

@radiantshaw

I was testing the pin_all_from method and found what might be a potential issue. pin_all_from requires both the :to and :under options to be passed for this test case to pass:

test "directory pin under custom asset path" do
assert_match %r|assets/spina/controllers/another_controller-.*\.js|, generate_importmap_json["imports"]["controllers/spina/another_controller"]
assert_match %r|assets/spina/controllers/deeper/again_controller-.*\.js|, generate_importmap_json["imports"]["controllers/spina/deeper/again_controller"]
end

This is also apparent by removing the line:

pin_all_from "app/javascript/spina/controllers", under: "controllers/spina", preload: true

from the setup and noticing that the tests still pass. I also verified it by creating a new Rails 7 app and adding both the lines:

pin_all_from "app/javascript/spina/controllers", under: "controllers/spina", preload: true
pin_all_from "app/javascript/spina/controllers", under: "controllers/spina", to: "spina/controllers", preload: true

to config/importmap.rb and running bin/importmap json. Commenting out the second line doesn't generate any imports but commenting out the first line does.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions