Options
All
  • Public
  • Public/Protected
  • All
Menu

envterpolate

Tiny Dotenv Environment Variable Interpolator

styled with prettier Greenkeeper badge Travis Coverage Status

This package implements a simple idea: interpolate strings taken from your npm package users, using variables they defined in their dotenv files. This is useful for those "last mile" customization that can't be committed to the repository (database parameters, passwords, etc)

Given two things:

  1. File: .env, written in dotenv syntax, containing a really important password, NOT committed to repo and added to .gitignore:

    MY_SECRET_PASSWORD=(|-|U(|< |\|0rr15
    
  2. File: package.json, with strings containing variables defined in .env:

    packageJson = {
    // ...
    "yourPluginConfig": {
     cliArgs: "--save --password ${MY_SECRET_PASSWORD}"
    }
    // ...
    }
    

... Then you can use envterpolate to read the file with the dotenv environment variables expanded:

import {interpolateJson} from 'envterpolate';

const packageJson = interpolateJson('package.json', '.env')
console.log(packageJson)
/**
{
  // ...
  "yourPluginConfig": {
    cliArgs: "--save --password (|-|U(|< |\|0rr15"
  }
  // ...
}
**/

Index

External modules

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc