Support for Powershell environment variables in hooks
Apollo-Roboto opened this issue · comments
The environment variables doesn't seem to work when used with Powershell.
Here is a hook example using the tailwindcss cli from a Powershell terminal. I'm trying to target the trunk staging directory.
[[hooks]]
stage = "build"
command = "tailwindcss"
command_arguments = ["-i", "./src/tailwind.css", "-o", "$($env:TRUNK_STAGING_DIR)/tailwind.css"]
However, this causes issues:
[Error: ENOENT: no such file or directory, mkdir 'C:\project_path\$($Env:TRUNK_STAGING_DIR)'] {
errno: -4058,
code: 'ENOENT',
syscall: 'mkdir',
path: 'C:\\project_path\\$($Env:TRUNK_STAGING_DIR)'
}
A similar example using sh
as the command works just fine.
[[hooks]]
stage = "build"
command = "sh"
command_arguments = ["-c", "./tailwindcss -i src/tailwind.css -o $TRUNK_STAGING_DIR/tailwind.css"]
I'm dumb dumb, someone helped me and this won't work because the argument is being passed as is to the tailwind cli
I'll close the issue, but here are solutions:
[[hooks]]
stage = "build"
command = "pwsh"
command_arguments = ["-Command", "tailwindcss -i ./src/tailwind.css -o $env:TRUNK_STAGING_DIR/tailwind.css"]
[[hooks]]
stage = "build"
command = "cmd"
command_arguments = ["/C", "tailwindcss -i ./src/tailwind.css -o %TRUNK_STAGING_DIR%/tailwind.css"]