yanv
v1.1.0
Published
preprocessor for .env file using the YAML format
Downloads
182
Readme
Yanv
Tiny CLI that converts any YAML file into a .env file.
ℹ️ This lib is intended to be used with the dotenv
lib.
✨ Features
The package includes the following features:
- watch for file change:
--watch
or-w
- run a command after .env generation:
--command
or-c
- take custom file:
--file
or-f
- look for YAML .env with specific suffix file:
--suffix
or-s
- output in a .env file instead of running command with the loaded environment:
--output
or-o
- avoid overriding existing environment variables:
--noOverride
or-n
Get started
- Install the dependecy as dev dependency:
npm install --dev yanv
yarn add --dev yanv
pnpm add --save-dev yanv
- Use
yanv
in your package.json scripts like:
# Basic usage. Will build .env.yaml or .env.yml
yanv
# Run a command and watch for env. changes
yanv -c 'yarn dev' --watch
# Look for .env.staging.yaml or .env.staging.yml
yanv -s 'staging' --watch
# Look for a specific file
yanv -c 'yarn dev' --watch --file yanv/my-yanv.yaml
Why this lib?
At Fifteen, we have some projects with a lot a .env configurations in variables, including ones which change frequently for internal testing (API URLs, theming, config...).
We developped this lib to suit our needs, notably by using the --watch
and --command
options.