3.2.14 • Published 28 days ago

dk-compare-env v3.2.14

Weekly downloads
-
License
MIT
Repository
github
Last release
28 days ago

Comparison utility for .env files

coverage npm license

In enterprise projects you often need to pass some environment params to your application. The good way is to create different files like

.env
example.dev.env
example.prod.env

and include them using dotenv. It's also good to create env.ts file that will parse this params in accordance with expected types, filters some secret data and could be imported in application.

Current .env should be always git-ignored so no sensitive data is leaked and every server or developer could configure it as he likes.

But when you deal with different files with similar structure there is always way to make a mistake - for example example.dev.env was changed, so local .env on other dev's machine becomes out-of-date, which leads to application error.

Purpose of this lib

  • compares different .env files and prints absent keys
  • compares .env keys with those in env.ts

Usage

  1. Add dk-compare-env to package.json
  2. Call before you start your build
const path = require('path');

import { compareEnvFiles } from 'dk-compare-env';

import { env } from './env';

compareEnvFiles({ 
  paths: [
    path.resolve(__dirname, '.env'),
    path.resolve(__dirname, 'example.dev.env'),
    path.resolve(__dirname, 'example.prod.env'),
  ],
  parsedEnvKeys: Object.keys(env) // optional
});

where paths are absolute paths and parsedEnvKeys (optional) is array of strings.

3.2.9

28 days ago

3.2.13

28 days ago

3.2.12

28 days ago

3.2.14

28 days ago

3.2.11

28 days ago

3.2.10

28 days ago

3.2.8

1 month ago

3.2.7

1 month ago

3.2.6

1 month ago

3.2.6-alpha.0

1 month ago

3.2.2

1 month ago

3.2.3

1 month ago

3.2.1

1 month ago

3.2.0

1 month ago

3.1.43

3 months ago

3.1.42

3 months ago

3.1.41

3 months ago

3.1.40

3 months ago

3.1.39

3 months ago

3.1.38

4 months ago

3.1.16

10 months ago

3.1.15

10 months ago

3.1.18

10 months ago

3.1.17

10 months ago

3.1.23

9 months ago

3.1.22

10 months ago

3.1.25

9 months ago

3.1.24

9 months ago

3.1.27

7 months ago

3.1.26

9 months ago

3.1.29

7 months ago

3.1.28

7 months ago

3.1.21

10 months ago

3.1.20

10 months ago

3.1.19

10 months ago

3.1.34

6 months ago

3.1.33

6 months ago

3.1.36

5 months ago

3.1.35

6 months ago

3.1.37

5 months ago

3.1.30

7 months ago

3.1.32

6 months ago

3.1.31

6 months ago

3.1.12

11 months ago

3.1.11

11 months ago

3.1.14

11 months ago

3.1.13

11 months ago

3.1.9

11 months ago

3.1.8

11 months ago

3.0.18

11 months ago

3.0.19

11 months ago

3.0.9

11 months ago

3.0.4

11 months ago

3.1.2

11 months ago

3.0.13

11 months ago

3.1.1

11 months ago

3.0.10

11 months ago

3.1.0

11 months ago

3.0.11

11 months ago

3.1.7

11 months ago

3.0.16

11 months ago

3.0.8

11 months ago

3.1.6

11 months ago

3.0.17

11 months ago

3.0.7

11 months ago

3.1.5

11 months ago

3.0.14

11 months ago

3.0.6

11 months ago

3.1.4

11 months ago

3.0.15

11 months ago

2.0.0

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago