Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Relative path inside a module

Tags:

module

raku

zef

I have this module which needs a specific file to work. You can pass the path of the file you want to use or not. If you don't, then a default file is taken. That default file is located at the resources folder, so I typed the path as: "resources/data/type-graph.txt". The problem is that does not work because it takes my CWD as root directory.

Do you know how to make the path relative to the module dir?

Any suggestion is appreciated :).

like image 367
Antonio Gamiz Delgado Avatar asked Jul 02 '19 09:07

Antonio Gamiz Delgado


1 Answers

You should take a look at the Modules documentation page. There this example is given to access a file placed in the resources folder:

my $template-text = %?RESOURCES<templates/default-template.mustache>.slurp;

You also need to list the file in META6.json so the file will be accessible once the module is installed.

{
    ...,
    "resources": [ "templates/default-template.mustache"]
}

As guifa noted in a comment %?RESOURCES works with individual files, not directory structures. It makes no guarantees of how the files are actually stored. So %?RESOURCES<templates>.dir will not work.

like image 155
Patrick Böker Avatar answered Sep 23 '22 23:09

Patrick Böker