The command that searches the current directory or parent directories for a specific file and returns the closest path.
There are two ways to install closest.
- Download the binary from GitHub Releases
- Install via aqua
Usage: closest [options] [pattern]
Options:
-a Search all files[default: false]
To find a closest file the current directory, run the following:
closest .tflint.hcl
To find all files from the current directory to root directory, run the following:
closest -a .envrc
tflint
only references .tflint.hcl
in the current or home directory.
This makes it easy to read per-project settings in the repository root or in the terraform directory in monorepo.
The directory structure is as follows, where staging
is the current directory.
/
└── home
└── app
└── terraform
├── .tflint.hcl
└── example-service
├── production
└── staging # <- current directory
To run tflint
in combination with closest
, run the following:
tflint --config $(closest .tflint.hcl)
Sometimes when using direnv
, you want to find where .envrc
is defined from the root directory to the current directory.
In that case, you can use the -a
option to display all .envrc
files up to the root directory, which is useful for troubleshooting.
The directory structure is as follows, where production
is the current directory.
/
└── home
└── app
├── .envrc
└── terraform
├── .envrc
└── example-service
├── .envrc
├── production # <- current directory
| └── .envrc
└── staging
To find all .envrc
from production
to the root directory, run the following:
closest -a .envrc
Please take care that the filename must be prefix with -a
.
For example, closest .envrc -a
doesn't work.
The output:
/home/app/terraform/example-service/production/.envrc
/home/app/terraform/example-service/.envrc
/home/app/terraform/.envrc
/home/app/.envrc