Socket
Socket
Sign inDemoInstall

node-dotconfig

Package Overview
Dependencies
5
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    node-dotconfig

Easily store and manage config files for your CLI


Version published
Weekly downloads
3
increased by200%
Maintainers
1
Install size
178 kB
Created
Weekly downloads
 

Readme

Source

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

FAQs

Last updated on 28 Apr 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc