stringify-env

1.0.0-beta1 • Public • Published

stringify-env

Version Downloads

Create files storing environment variables.

☁️ Installation

$ npm i --save stringify-env

📋 Example

import { item, toArray, toFile } from "stringify-env"
 
console.log(item("PORT", 8080));
// => PORT=8080
 
console.log(toArray({
    PORT: 8080
  , NODE_ENV: "production"
}));
// => [ 'PORT=8080', 'NODE_ENV=production' ]
 
// Will create a file named `.env` in this directory
toFile({
    PORT: 8080
  , NODE_ENV: "production"
}, __dirname, err => {
    err && console.error(err);
    // The .env file contains:
    // PORT=8080
    // NODE_ENV=production
});

❓ Get Help

There are few ways to get help:

  1. Please post questions on Stack Overflow. You can open issues with questions, as long you add a link to your Stack Overflow question.
  2. For bug reports and feature requests, open issues. 🐛
  3. For direct and quick help, you can use Codementor. 🚀

📝 Documentation

envToItem(name, value)

Converts the pair of name and value into a string.

Params

  • String name: The environment variable name.
  • String value: The environment variable value.

Return

  • String The stringified pair.

envToArray(obj)

Converts an object of environment variables into an array.

Params

  • Object obj: The object containing environment variables to stringify.

Return

  • Array An array of stringified pairs.

toFile(obj, dir, cb)

Create a file named .env in the specified directory.

Params

  • Object obj: The object containing environment variables to stringify.
  • String dir: = "" The directory where to create the .env file.
  • Function cb: The callback function.

Return

  • Stream The writable stream.

😋 How to contribute

Have an idea? Found a bug? See how to contribute.

📜 License

MIT © Bloggify

Package Sidebar

Install

npm i stringify-env

Weekly Downloads

0

Version

1.0.0-beta1

License

MIT

Last publish

Collaborators

  • ionicabizau