dotenv-shell

A dotenv package that expands shell commands

Usage no npm install needed!

<script type="module">
  import dotenvShell from 'https://cdn.skypack.dev/dotenv-shell';
</script>

README

dotenv-shell

Build Master

A package that expands shell commands from a dotenv config.

Install

npm install dotenv
npm install dotenv-shell

Usage

Wrap dotenv-shell around dotenv to expand shell commands.

You .env file should look something like this:

BASIC=`echo basic`

You script should look something like this:

const dotenv = require('dotenv')
const dotenvExpand = require('dotenv-shell')
const config = dotenv.config();
dotenvShell(config);
console.log(config);
// { parsed: { BASIC: 'basic' } }

You can further expand with the dotenv-expand package.

npm install dotenv
npm install dotenv-shell
npm install dotenv-expand
EXPAND=basic
BASIC=`echo ${EXPAND}`
const config = dotenvShell(dotenvExpand(dotenv.config()));
console.log(config);
// { parsed: { EXPAND: 'basic', BASIC: 'basic' } }

Notes

Please request features or report problems using the issues page.

License

See the included LICENSE for rights and limitations under the terms of the MIT license.