dotenv-generate-helper
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.
Installation
Via npm:
$ npm install [-g] dotenv-generate-helper
Command line use
$ collect-env-used-in-file path-to-config-that-uses-env-vars
For example
$ collect-env-used-in-file ./config.js
Import helper
import { DotEnvHelper } from 'dotenv-generate-helper';
Usage
Collect env
; // tslint:disable:no-consoleDotEnvHelper.prepare; ; console.info'Collected env:', JSON.stringifyDotEnvHelper.accessedEnvMap, null, 2;
Generate env
; // tslint:disable:no-consoleDotEnvHelper.collectEnvUsedInFile'./config' .thenconsole.info'.env file generated' .catchconsole.error;
Or You can do it like this:
; DotEnvHelper.prepare; require'./file1';require'./file2';require'./file3'; // tslint:disable:no-consoleDotEnvHelper.save .thenconsole.info'.env file generated' .catchconsole.error;