# grunt-gen-env

> Generating environment files from a configuration file.

Latest version **0.2.0** (published 2018-06-25) · 0 weekly downloads

## Install

```sh
npm install grunt-gen-env
pnpm add grunt-gen-env
yarn add grunt-gen-env
bun add grunt-gen-env
```

## Health

**Score 10/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2018-06-25 |
| First published | 2015-11-19 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 9 |
| Dependencies | 0 |
| Unpacked size | 9.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Sorenson Media |
| Maintainers | brandonbuttars |
| Keywords | gruntplugin |

## Links

- npm: https://www.npmjs.com/package/grunt-gen-env
- Repository: https://github.com/sorenson/grunt-gen-env
- Issues: https://github.com/sorenson/grunt-gen-env/issues
- npm.io page: https://npm.io/package/grunt-gen-env

## Recent versions

- 0.2.0 (latest) — 2018-06-25
- 0.1.5 — 2018-06-25
- 0.1.4 — 2016-01-19
- 0.1.3 — 2015-11-20
- 0.1.0 — 2015-11-19

## README

# grunt-gen-env

> Generating environment files from a configuration file.  Works great with http://stout.is/.

## Getting Started
This plugin requires Grunt `^1.0.3`

If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

```shell
npm install grunt-gen-env --save-dev
```

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

```js
grunt.loadNpmTasks('grunt-gen-env');
```

## The "grunt_gen_env" task

### Overview
In your project's Gruntfile, add a section named `grunt_gen_env` to the data object passed into `grunt.initConfig()`.

```js
grunt.initConfig({
  grunt_gen_env: {
    options: {
      // If you don't specify any options, they will use the values
      // listed below.
      assign_to_variable: false,
      global_variable: false,
      variable_name: 'ENV',
      src_file: 'default.environments.json',
      environment: 'development',
      target_directory: '.',
      file_name: 'environment.js'
    },
    development: {
      // Label this block whatever you want and add any environment
      // specific options from above here.  Any options not specified
      // here will fall back to the defaults.
    }
  },
});
```

### Options

#### options.assign_to_variable
Type: `Boolean`
Default value: `false`

By default the environment isn't assigned to a variable. To assign the object to a variable, assign this value to true.

#### options.global_variable
Type: `Boolean`
Default value: `false`

By default the variable isn't a global variable. To make the variable global, assign this value to true.

#### options.variable_name
Type: `String`
Default value: `'ENV'`

If the value of `'assign_to_variable'` is `'true'`, this `'variable_name'` is the name of the variable that the environment Object will be assigned to.

#### options.src_file
Type: `String`
Default value: `'environments.json'`

Path of the `json` file represented as a `String`. If this file doesn't exist, it will try `'default.environments.json'` or the `'src_file'` you've assigned with a prefix of `'default.'`

#### options.environment
Type: `String`
Default value: `'development'`

The `Object` name of the environment that is being used in the `options.src_file`.  This value needs to be a `String`.

#### options.file_name
Type: `String`
Default value: `'environment.js'`

`String` name of the file with `js` extension appended to it.

#### options.target_directory
Type: `String`
Default value: `'.'`

The `String` name/path of where the `environment file` will be written to.


### Sample Environments File

```
{
  "local": {
    "api": "http://local.api.com",
    "auth": "http://local.auth.com"
  },
  "development": {
    "api": "http://dev.api.com",
    "auth": "http://dev.auth.com"
  },
  "production": {
    "api": "http://api.com",
    "auth": "http://auth.com"
  }
}
```

## Release History
0.1.3 - [New Releases](https://github.com/sorenson/grunt-gen-env/releases/tag/0.1.3) - 11/20/2015
0.1.2 - [New Releases](https://github.com/sorenson/grunt-gen-env/releases/tag/0.1.2) - 11/20/2015
0.1.1 - [Official First Releases](https://github.com/sorenson/grunt-gen-env/releases/tag/0.1.1) - 11/20/2015

---
_Source: https://npm.io/package/grunt-gen-env · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
