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

Functions in replacement syntax #165

Open
guybedford opened this issue Mar 13, 2023 · 1 comment
Open

Functions in replacement syntax #165

guybedford opened this issue Mar 13, 2023 · 1 comment

Comments

@guybedford
Copy link
Owner

guybedford commented Mar 13, 2023

We currently support replacement syntax like GitHub actions via ${{ }} which currently is only supported in ENV, but could be extended to further strings.

This replacement syntax currently only supports a single uppercase expression of another ENV var to replace into the string.

The proposal would be to extend the replacement system to support functions - someFunction(...) with comma-separated arguments, including strings and literals.

For example:

[env]
NAME = "${{ readFile('name.txt') }}"

would set an environment variable from the contents of a file.

Common configuration formats could also be supported:

[env]
VERSION = "${{ json('package.json', 'version') }}"

would set the VERSION environment variable to the contents of the package.json "version" field.

There would be no participation in the task graph, so one would still need to add these files into the task graph normally.

Alternatively we could automatically treat any file dependencies caused by these functions as dependencies of all tasks, just like in theory the chompfile.toml itself should really be. Possibly even exposing this feature separately as a top-level global-deps = ["chompfile.toml"], for dependencies of all tasks.

@guybedford
Copy link
Owner Author

Global environment functions referencing files would be global dependency additions, while task-local environment functions referencing files would be task-specific dependency additions.

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

No branches or pull requests

1 participant