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

Modules: add relative path support to import.file #789

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

wildum
Copy link
Contributor

@wildum wildum commented May 8, 2024

PR Description

This PR introduces an ArgScope to the loader that will be used as a parent scope when evaluating the nodes in the module. For now, it contains only one variable "module_path" that represents the current path of the module and can be used in the config. It also adds the stdlib function "path_join". Both can be used together to configure a relative path on the import.file block.

import.file “default” {
  filename = path_join(module_path, "relative/path")
}

The following use-cases are currently supported:

  • import.file in a module imported via import.file (module_path = filename of the parent import.file)
  • import.file in a module imported via import.git (module_path = path to the local cloned repo)
  • import.file in a module imported via import.string (module_path = path of the current module)

Which issue(s) this PR fixes

Fixes #786

Notes to the Reviewer

The PR can be reviewed commit by commit.

PR Checklist

  • CHANGELOG.md updated
  • Documentation added
  • Tests updated

wildum added 11 commits May 7, 2024 12:09
…l context to the module.

The scope has one value "module_path" that represents the dir path of the current module.
It can be used in combination with the path_join stdlib function to import modules via relative path.
- import file in import file with relative path
- import folder in import folder with relative path
- import file in import string with relative path
@wildum wildum force-pushed the modules-support-relative-path branch from 538437d to 000b538 Compare May 10, 2024 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Modules: support relative path
1 participant