Integration
There are a few different ways to integrate Varlock into your application.
Universal
Section titled “Universal”The most universal way to use varlock in your code is via varlock run.
varlock run -- <your-command>This will validate your environment variables and then run the command you provided with the validated environment variables injected into the process.
JavaScript ecosystem
Section titled “JavaScript ecosystem”Node - auto-load
Section titled “Node - auto-load”varlock can be used in any Node.js application by importing the auto-load module. This will automatically load the environment variables into process.env.
import 'varlock/auto-load';
const MY_CONFIG_ITEM = process.env.MY_CONFIG_ITEM;Overrides - dotenv
Section titled “Overrides - dotenv”If you are using dotenv to load your environment variables, you can use the overrides feature to use varlock instead.
"overrides": { "dotenv": "varlock" } "overrides": { "dotenv": "varlock" }overrides: dotenv: varlockpackage.json scripts
Section titled “package.json scripts”You can also use varlock in your package.json scripts by using the varlock run command.
"scripts": { "start": "varlock run -- node index.js"}