@tuplo/envsubst
TypeScript icon, indicating that this package has built-in type declarations

1.15.2 • Public • Published

envsubst

Substitutes the values of environment variables. Based on GNU envsubst.

Usage

import envsubst from '@tuplo/envsubst';

Substitutes the values of environment variables

process.env = { ENV_VAR1: 'bar' };

envsubst('foo=$ENV_VAR1'); // → foo=bar

envsubst('foo=${ENV_VAR1}'); // → foo=bar

envsubst('foo={{ENV_VAR1}}'); // → foo=bar

If shellFormat is present, replaces only those variables

process.env = { ENV_VAR1: 'bar', ENV_VAR2: 'baz' };

envsubst('$ENV_VAR1 $ENV_VAR2', '$ENV_VAR2'); // → $ENV_VAR1 baz

API

envsubst(input, [shellFormat])

input: string

A string with references to environment variables of the form $VARIABLE, ${VARIABLE} or {{VARIABLE}}.

shellFormat: string

The output consists of the environment variables that are referenced in shellFormat.

Install

$ npm install @tuplo/envsubst

# or with yarn
$ yarn add @tuplo/envsubst

Contribute

Contributions are always welcome!

License

MIT

Package Sidebar

Install

npm i @tuplo/envsubst

Weekly Downloads

764

Version

1.15.2

License

MIT

Unpacked Size

7.12 kB

Total Files

6

Last publish

Collaborators

  • tuplo