New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

file-config-reader

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

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.

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by50%
Maintainers
1
Weekly downloads
 
Created
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

Package last updated on 15 Sep 2014

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc