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
- Host: GitHub
- URL: https://github.com/garyb432/venv
- Owner: GaryB432
- License: mit
- Created: 2017-08-13T00:43:47.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-25T18:11:21.000Z (over 8 years ago)
- Last Synced: 2025-03-29T15:01:44.580Z (11 months ago)
- Topics: environment-variables, javasscript
- Language: TypeScript
- Homepage:
- Size: 43.9 KB
- Stars: 3
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# venv
[](https://marketplace.visualstudio.com/items?itemName=garybortosky.venvextension)
[](https://travis-ci.org/GaryB432/venv)
[](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