Socket
Socket
Sign inDemoInstall

file-config-reader

Package Overview
Dependencies
10
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    file-config-reader

A simple module for loading/merging local and global JSON configuration files.


Version published
Weekly downloads
1
Maintainers
1
Install size
1.15 MB
Created
Weekly downloads
 

Readme

Source

file-config-reader

A simple module for reading and merging config files that are stored "locally" (current working tree) and "globally" (home directory).

This module was built primarily for use when writing command-line (CLI) programs in Node.js. It implements some features from a few of my favorite command-line applications:

  • JSHint - looks for config files not just in the working directory, but also in parent directory.
  • Git - looks for config files in both a "local" and "global" location.

Instead of passing options to the command-line, it's often beneficial to store program-specific options in a configuration file. Additionally, you may want to maintain project-specific configuration files and/or a global configuration file for shared cross-project settings (i.e. 'git'). Also, when working within subdirectories of a project folder, it's often useful for a command-line utility to search upwards in the directory tree for a configuration file, so you don't constantly need to navigate back to the location of the configuration file (i.e. JSHint).

Note: Currently, this module only supports files with JSON content.

Install

npm install file-config-reader --save

Usage

> pwd
/Users/andre/dev/projects/cli_reader

> cat conf.json
{
  "projectName": "cli_reader_sample",
  "email": "no-reply@andregiannico.com"
}

> cat $HOME/conf.json
{
  "firstName": "Andre",
  "lastName": "Giannico",
  "email": "andre@andregiannico.com",
  age: 31
}
var FileConfigReader = require('file-config-reader');

var conf = new FileConfigReader('conf.json');

console.log(conf.firstName);

// output
"Andre"

console.log(conf);

// output
{
  projectName: "cli_reader_sample",
  firstName: "Andre",
  lastName: "Giannico",
  email: "no-reply@andregiannico.com",
  age: 31
}

License

Copyright 2014 Andre Giannico MIT License (enclosed)

Keywords

FAQs

Last updated on 15 Sep 2014

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