Convert your dotenv files to their YAML equivalent.
npm install dotenv-to-yamlConvert your dotenv files to their YAML equivalent.
I initially developed this package to easily deploy Google Cloud Functions because the gcloud CLI does not understand
dotenv files.
> Extracted from the gcloud functions deploy docs:
>
> --env-vars-file=FILE_PATH
>
> Path to a local YAML file with definitions for all environment variables. All existing environment variables will be removed before the new environment variables are added.
Install locally (inside a project where a package.json is defined):
``shell`
npm install dotenv-to-yaml
Note: you may want to use the --dev flag if you are only interested in the CLI feature.
Global usage:
`shell
dotenv-to-yaml [source] [destination]
Transform a dotenv file to YAML one
Positionals:
source The source dotenv file or - if the file content is piped to-
STDIN. [string] [default: ".env"]
destination The destination YAML file or to pipe the conversion result to
STDOUT. [string] [default: ".env.yaml"]
`
#### Piping from STDIN
dotenv-to-yaml supports piping the dotenv content through STDIN; the converted output will be sent to STDOUT.
Example:
`shell`
dotenv-to-yaml < samples/bedrock.env
will print:
`yamlMB^lb
AUTH_KEY: qVQ9646_?j46vlO^j$;cGY/|;4i7z%&&bk/O#rex[.72@R8_{9h8#D$|8@7_Wj
SECURE_AUTH_KEY: SoHEtm!HO3M2r#Z$3l]PX}aSc-hyLq95m_w7oY=a]fOM4b[/Q^=LqAU-y;/C#t24^>i[@WG/1SsnoQU*bfmdf#p9e%Zo(xe?b9CJ(tZD;:^o3
LOGGED_IN_KEY: dt{MU>/B9YO.V)M#3Ho=QmJc4s:/WC58r%CZTrQkx7jpgRvrO@iDYo[COU8X*=C|
NONCE_KEY: '*#XT#t,y2ucBk87C;88;0(Cwq+zA1()WIwsR!P4TIzJQZPA2P$Saww8xQ(GDx_y]'
AUTH_SALT: .J2bEZQvDKMM%kWwdgXFf/q/&10c7AtSbl%NLH.3j.}.4.|MPdC,Tnp$:|i#sF)y
SECURE_AUTH_SALT: /DdIXg_TI|E
LOGGED_IN_SALT: c5AMtWe?Nut]sVo5Sdw4:)N,togVS6L{IvRvCxi>;VJyz4xDE$&X#q4)JB<#LUH`
NONCE_SALT: Nmfdg*9@x$tdb[TZj.1-p)(
#### Specifying source and destination
`shell`
dotenv-to-yaml .env .env.yaml
`javascript`
const { dotenvToYAML } = require('dotenv-to-yaml');
`typescript``
import { dotenvToYAML } from 'dotenv-to-yaml';
// OR with default import:
import dotenvToYAML from 'dotenv-to-yaml';