node-dotconfig
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i node-dotconfig

Weekly Downloads

3

Version

1.0.4

License

MIT

Unpacked Size

101 kB

Total Files

24

Last publish

Collaborators

  • caroso1222