Skip to content

VSCode and terragrunt #801

Answered by denis256
sarkis asked this question in Help
Jan 29, 2024 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

Hi,
yes, now terragrunt hclfmt formats all files even before visual code save file, in my projects I use workaround script format.sh which save stdin to a temporary file, run formatting on it and read it back:

#!/bin/bash
temp_file=$(mktemp)
# save input to a temp file
cat > "$temp_file"
# format single file
terragrunt hclfmt --terragrunt-hclfmt-file "$temp_file"
# print rendered file
cat "$temp_file"
# clean temporary file
rm -f "$temp_file"

Configuration in settings.json:

{
  "editor.formatOnSave": true,
  "[hcl]": {
    "editor.defaultFormatter": "jkillian.custom-local-formatters",
  },
  "customLocalFormatters.formatters": [
    {
      "command": "./format.sh",
      "languages": [
…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@sarkis
Comment options

Answer selected by sarkis
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment