1.0.4 • Published 4 years ago

node-dotconfig v1.0.4

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

node-dotconfig

npm version Build Status codecov

Easily create and read config files from the user's home directory.

  • 🐝 Config files saved in ini format
  • 🏆 Cross-platform support for Windows, Linux and macOS.
  • 💥 Typings readily available
  • 🏄‍♂️ Promise-based API
  • 🥑 Proper support for nested config objects

Read the docs.

Motivation

This utility is useful when you want to save .my-app config files in the user's home directory. CLIs are well known to use this technique for saving user's preferences.

Installation

npm i node-dotconfig

Usage

import { createConfig, readConfig } from 'node-dotconfig';

async function config() {
  await createConfig('.my-cli', { user: { name: 'johndoe', apiKey: '12345' } });
  const config = await readConfig('.my-cli');
  console.log(config.user.name); // 'johndoe'
}

Running the code above will create the file ~/.my-cli with the following content:

[user]
name=johndoe
apiKey=12345

API

Licence

MIT © Carlos Roso