Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Bloggify/obj2env

Repository files navigation

obj2env

Version Downloads

Create files storing environment variables by using objects.

Use dotenv for loading an .env file in your application.

☁️ Installation

# Using npm
npm install --save obj2env
# Using yarn
yarn add obj2env

πŸ“‹ Example

var { item, toArray, toFile } = require("obj2env")
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. πŸ›

πŸ“ 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 (default: the current directory).
  • Function cb: The callback function.

Return

  • Stream The writable stream.

πŸ˜‹ How to contribute

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

πŸ’« Where is this library used?

If you are using this library in one of your projects, add it in this list. ✨

  • obj2env-cli

πŸ“œ License

MIT Β© Bloggify

About

πŸ“‹ Create files storing environment variables by using objects.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /