This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
admin-panel/graphql-types/node_modules/string-env-interpolation
2021-03-09 19:44:13 +01:00
..
index.cjs.js add configured graphql-codegen 2021-03-09 19:44:13 +01:00
index.cjs.js.map add configured graphql-codegen 2021-03-09 19:44:13 +01:00
index.d.ts add configured graphql-codegen 2021-03-09 19:44:13 +01:00
index.d.ts.map add configured graphql-codegen 2021-03-09 19:44:13 +01:00
index.esm.js add configured graphql-codegen 2021-03-09 19:44:13 +01:00
index.esm.js.map add configured graphql-codegen 2021-03-09 19:44:13 +01:00
package.json add configured graphql-codegen 2021-03-09 19:44:13 +01:00
README.md add configured graphql-codegen 2021-03-09 19:44:13 +01:00

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