An open API service indexing awesome lists of open source software.

https://github.com/garyb432/venv

Use build- or release-time environment variables in your javascript project
https://github.com/garyb432/venv

environment-variables javasscript

Last synced: 10 months ago
JSON representation

Use build- or release-time environment variables in your javascript project

Awesome Lists containing this project

README

          

# venv

[![VSTS Extension](https://vsmarketplacebadge.apphb.com/version/garybortosky.venvextension.svg)](https://marketplace.visualstudio.com/items?itemName=garybortosky.venvextension)
[![Build Status](https://travis-ci.org/GaryB432/venv.svg?branch=master)](https://travis-ci.org/GaryB432/venv)
[![npm version](https://badge.fury.io/js/venv.svg)](https://badge.fury.io/js/venv)

Make build-time environment variables available to your application.

Venv uses [EJS](https://ejs.co) to transform a template file using Node's `process.env` map.

## CLI Usage

Usage: `venv [options]`

Your build or deploy pipeline could include

```
npm install venv -g
venv process -t src\environments\environment.prod.ts
```

### Commands:

### process

- appends `.template` to the filename passed as argument `t`
- transforms that file using `process.env` as the context
- saves the result to the original name supplied on the command line

### Options:

```
-t, --templatePath the path to the template file
-h, --help show help
-v, --version current version
```

#### Example

> venv process --templatePath assets\env.js

__assets\env.js.template__:
```javascript
(function (window) {
window.__env = window.__env || {};
window.__env.BUILD_BUILDNUMBER = '<%= env.BUILD_BUILDNUMBER %>';
}(this));
```

```html



console.log(__env.BUILD_BUILDNUMBER);

```

## Exit Codes

The CLI process may exit with the following codes:

- `0`: Transform succeeded without errors
- `1`: An invalid command line argument or combination thereof was used
- `2`: Transform failed