Skip to content
/ venv Public

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

License

Notifications You must be signed in to change notification settings

GaryB432/venv

Repository files navigation

venv

VSTS Extension Build Status npm version

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 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:

(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 errors
  • 1: An invalid command line argument or combination thereof was used
  • 2: Transform failed

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published