node-dotconfig
Easily store and manage config files for your CLI
Last updated 6 months ago by caroso1222 .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install node-dotconfig 
SYNC missed versions from official npm registry.

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

Current Tags

  • 1.0.4                                ...           latest (6 months ago)

3 Versions

  • 1.0.4                                ...           6 months ago
  • 1.0.2                                ...           6 months ago
  • 1.0.0                                ...           6 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (17)
Dependents (1)

Copyright 2014 - 2017 © taobao.org |