Package Exports
- string-env-interpolation
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (string-env-interpolation) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
string-env-interpolation
Use string interpolation to provide Environment Variables.
Installation
yarn add string-env-interpolation
npm install string-env-interpolation
Usage
Let's say we have a config file: config.yaml
.
debug: ${DEBUG:false}
name: ${NAME:"Development"}
user: ${USER}
Our library wants to be able to consume environment variables in index.js
.
import { env } from "string-env-interpolation";
import { readFileSync } from "fs";
const content = env(readFileSync("./config.yaml", "utf-8"));
console.log(content);
Outputs:
DEBUG=true USER=kamil node index.js
# Output
debug: true
name: Development
user: kamil
NAME=Production USER=kamil node index.js
# Output
debug: false
name: Production
user: kamil