Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Commit 5c40ef6

Browse files
committed
Improve documentation
1 parent f0ac2e9 commit 5c40ef6

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,23 @@
11
# dottfvars
2+
3+
Parses a `.tfvars` or `.tfvars.json` file and adds the key value pairs
4+
to the node environment variables (`process.env`). This module is
5+
intended to be used in conjunction with the
6+
[`env-var` module](https://www.npmjs.com/package/env-var).
7+
8+
## Usage
9+
10+
Can parse `.tfvars` files
11+
12+
```ts
13+
import {resolve} from 'path'
14+
15+
dottfvars.from(resolve(__dirname, 'iac/development.tfvars'))
16+
const imageId = env.from(process.env).get('image_id').asString()
17+
```
18+
19+
Alternatively, you may define your tfvars as JSON and pass in a
20+
`.tfvars.json` file path instead.
21+
22+
Related Packages:
23+
- [env-ssm](https://github.com/byu-oit/env-ssm#readme)

test/dottfvars.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ import * as env from 'env-var'
33
import * as dottfvars from '../src/dottfvars'
44

55
test('parses .tfvars file', async () => {
6-
await dottfvars.from(resolve(__dirname, 'examples/good.tfvars'))
6+
dottfvars.from(resolve(__dirname, 'examples/good.tfvars'))
77
const imageId = env.from(process.env).get('image_id').asString()
88
const availabilityZoneNames = env.from(process.env).get('availability_zone_names').asJsonArray()
99
expect(typeof imageId).toBe('string')
1010
expect(availabilityZoneNames).toHaveLength(2)
1111
})
1212

1313
test('parses tfvars.json file', async () => {
14-
await dottfvars.from(resolve(__dirname, 'examples/good.tfvars.json'))
14+
dottfvars.from(resolve(__dirname, 'examples/good.tfvars.json'))
1515
const imageId = env.from(process.env).get('image_id').asString()
1616
const availabilityZoneNames = env.from(process.env).get('availability_zone_names').asJsonArray()
1717
expect(typeof imageId).toBe('string')

0 commit comments

Comments
 (0)