Skip to content

Allow danger.import_dangerfile(path:) with full file path #1379

Description

@jkmathew

Report

I'm trying to split Dangerfile into multiple smaller files.
For that, I am trying to use danger.import_dangerfile(path:'scripts/DangerExtensions/child_danger1.rb') method.
But this gives the error
[!] Invalid Dangerfile file: Not a directory @ rb_sysopen - scripts/DangerExtensions/child_danger1.rb/Dangerfile. Updating the Danger gem might fix the issue. Your Danger version: 8.5.0, latest Danger version: 8.6.1

What did you expect to happen?

When giving the full path to this method, danger should import the file and run it.

What happened instead?

When giving the full path to this method, danger blindly appends Dangerfile to it and tries to open the file.

def import_dangerfile_from_path(path)
raise "`import_dangerfile_from_path` requires a string" unless path.kind_of?(String)
local_path = File.join(path, "Dangerfile")
@dangerfile.parse(Pathname.new(local_path))
end

With this, if I have multiple files, I have to place each file with the name Dangerfile in separate folders, which is a limitation I would say.

Your Environment

  • Which CI are you running on?
    Github actions

  • Are you running the latest version of Danger?
    Danger version 8.5.0

  • What is your Dangerfile?

    danger.import_dangerfile(path: 'scripts/DangerExtensions/child_danger1.rb')

PS: I am happy to open a PR to fix this if maintainers agree with this 🙂

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions