Substitutes the values of environment variables. Based on GNU envsubst.
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=barIf shellFormat is present, replaces only those variables
process.env = { ENV_VAR1: 'bar', ENV_VAR2: 'baz' };
envsubst('$ENV_VAR1 $ENV_VAR2', '$ENV_VAR2'); // → $ENV_VAR1 bazA string with references to environment variables of the form $VARIABLE, ${VARIABLE} or {{VARIABLE}}.
The output consists of the environment variables that are referenced in shellFormat.
$ npm install @tuplo/envsubst
# or with yarn
$ yarn add @tuplo/envsubstContributions are always welcome!
MIT