A helper created to generate .env file of accessed ENV variables with its values. It assumes that You have dotenv installed to be able to load ENV variables from .env file.
Via npm:
$ npm install [-g] dotenv-generate-helper
$ collect-env-used-in-file path-to-config-that-uses-env-vars
For example
$ collect-env-used-in-file ./config.js
import { DotEnvHelper } from 'dotenv-generate-helper';
import { DotEnvHelper } from 'dotenv-generate-helper';
// tslint:disable:no-console
DotEnvHelper.prepare();
import './config';
console.info('Collected env:', JSON.stringify(DotEnvHelper.accessedEnvMap, null, 2));
import { DotEnvHelper } from 'dotenv-generate-helper';
// tslint:disable:no-console
DotEnvHelper.collectEnvUsedInFile('./config')
.then(() => console.info('.env file generated'))
.catch(console.error);
Or You can do it like this:
import { DotEnvHelper } from 'dotenv-generate-helper';
DotEnvHelper.prepare();
require('./file1');
require('./file2');
require('./file3');
// tslint:disable:no-console
DotEnvHelper.save()
.then(() => console.info('.env file generated'))
.catch(console.error);