-
Notifications
You must be signed in to change notification settings - Fork 3
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
Dynamic args and params #42
Comments
Or even better would be to have a hook system like @pnpm , so a custom chunk of ps1 can re-process the dependency entry and fiddle with it before fudge processes it. |
Another important use of this would be loading the version dynamically from |
Hooks in choco itself is chocolatey/choco#1185 |
This could actually be really easily achieved using the Idea is to basically take the string, convert it to a scriptblock, and invoke it like PowerShell: # take the args from the fudgefile
$args = "path=$(where.exe choco)"
$args = (. ([scriptblock]::Create('return "$($args)"')))
# args is now
"path=C:\ProgramData\chocolatey\bin\choco.exe" This also raises a point for For the hooks, I really like the idea; be good as a new feature request! You could have both this and the hooks. Right now there's pre/post hooks for before/after all packages, but we could have pre/post-package hooks that run before/after each package. Then maybe let each package have it's own individual pre/post hooks? |
Embedding PS into JSON? :P Hence #59 , as YAML is better for writing code snippets inside config. Another approach for some dynamic uses of "args" and "params", slightly less pretty but less convoluted and more consistent, is to use CMD syntax, This doesnt provide a nice approach for dynamically choosing whether to (It would be very useful to have a PS implementation of .CMD file parser.) |
Haha, yeeeeah it's not great, but for simple inline stuff like In which case, we could have:
|
Another option is to allow This is like |
I was just thinking about changing the JSON file to a Hashtable format last night - possibly better than #59? Since changing the file format is a v2.0 change - maybe having the |
Why not support both JSON and .psd1 ? That avoids a breaking change , avoids needing to rewrite all the documentation, and lets the .psd1 support be 'beta' and allowed to change over the next few versions until we're confident it is ready to be stable. For my part, my next iteration will be importing Fudge.ps1 and FudgeTools into the coala central mobans repo, so you cant break us - you can only prevent us from upgrading fudge. With my learnings at #58 (comment) , I think e.g. the original problem can be solved by hook $package.args = ("/PHP=" + (fudge which php)) And if that if ($action -eq 'install') {
$package.args = ("/PHP=" + (fudge which php))
} And if ($action -eq 'install') {
$package.args = $package.args -replace '%PHP_ROOT%',(fudge which php)
}
else {
$package.args = $null
}
|
Composer needs to know where php is located, so it would look something like this:
But it would be much nicer if there were not hard-coded directories could be something like
or perhaps
There is already a dependency between the composer and php packages, so the dynamic scriptlet only needs to be run just before composer is ready to be installed.
The text was updated successfully, but these errors were encountered: