venv
v1.0.1
Published
Use build-time environment variables in your application
Downloads
304
Maintainers
Readme
venv
Make build-time environment variables available to your application.
Venv uses EJS to transform a template file using Node's process.env
map.
CLI Usage
Usage: venv <cmd> [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 argumentt
- 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:
(function (window) {
window.__env = window.__env || {};
window.__env.BUILD_BUILDNUMBER = '<%= env.BUILD_BUILDNUMBER %>';
}(this));
<html>
<head>
<meta charset="utf-8">
<script src="assets/env.js"></script>
</head>
<body>
<script>
console.log(__env.BUILD_BUILDNUMBER);
</script>
</body>
</html>
Exit Codes
The CLI process may exit with the following codes:
0
: Transform succeeded without errors1
: An invalid command line argument or combination thereof was used2
: Transform failed