Socket
Book a DemoInstallSign in
Socket

babel-plugin-transform-environment-variables-to-getters

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-transform-environment-variables-to-getters

The babel plugin to transform inline environment variables to value getters

latest
Source
npmnpm
Version
2.0.1
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status Coverage

babel-plugin-transform-environment-variables-to-getters

The babel plugin to transform inline environment variables to value getters

Install

$ npm i babel-plugin-transform-environment-variables-to-getters

Example

In

console.log(process.env.NODE_ENV)
console.log(process.env.NODE_DEBUG)

Out

Via .babelrc with no options.exclude/include

{
  "plugins": [
    ["transform-environment-variables-to-getters", {
      "envFilepath": "/path/to/get-env.js"
    }]
  ]
}

Out

// We can change __PROCESS_ENVS_GETTER__ with `webpack.DefinePlugin`
const __getProcessEnvs = require('/path/to/get-env.js')

console.log(__getProcessEnvs().NODE_ENV)
console.log(__getProcessEnvs().NODE_DEBUG)

Via .babelrc with options

{
  "plugins": [
    ["transform-environment-variables-to-getters", {
      "envFilepath": "/path/to/get-env.js",
      "exclude": ["NODE_DEBUG"]
    }]
  ]
}

Out

const __getProcessEnvs = require('/path/to/get-env.js')

console.log(__getProcessEnvs().NODE_ENV)

// process.env.NODE_DEBUG is excluded
console.log(process.env.NODE_DEBUG)

options Object

  • envFilepath path the path of the environment file which should be a literal string
  • getterIdentifier? string='__getProcessEnvs' the identifier name of the env getter method
  • include? Array<string> keys to include. If not specified, all keys which are not excluded will be included
  • exclude? Array<string> keys to exclude.

License

MIT

Keywords

environment-variables

FAQs

Package last updated on 10 May 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts