npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

config-file

v0.3.2

Published

Find and load a YAML or JSON config file (like .jshintrc, package.json, bower.json etc) from either a local project, installed npm module, or the user's home directory.

Downloads

235

Readme

config-file NPM version

Find and load a YAML or JSON config file (like .jshintrc, package.json, bower.json etc) from either a local project, installed npm module, or the user's home directory.

Heads up! Breaking changes

v0.3.0 was a complete refactor. The readme API section describes the new API.

Install

Install with npm

$ npm i config-file --save

Usage

var config = require('config-file');

API

config

Returns an object from parsing JSON or YAML from the given config file. Uses config.resovle to resolve the filepath. If no filepath is specified, config.resolve falls back to 'package.json'

Params

  • filename {String}: The name of the file to parse
  • options {Object}: Optionally specify {parse:'json'} or {parse:'yaml'}
  • returns {Object}

Example

var opts = config('.jshintrc');

.npm

Parse a config file located in a locally installed npm package (in node_modules).

Params

  • moduleName {String}: The name of the npm package to search in node_modules
  • filename {String}: Name of the file to find.
  • options {Object}

Example

var data = config.npm('read-data', 'package.json');
//=> { name: "read-data", ... }

.global

Parse a config file in a globally installed npm package.

Params

  • moduleName {String}: The name of the global module to search
  • filename {String}: Name of the file to find.
  • options {Object}

Example

var data = config.global('verb-cli', 'package.json');
//=> { name: "verb-cli", ... }

.home

Return a filepath the user's home directory

Params

  • filepath {String}: Filepath to find
  • options {Object}

Example

var data = config.home('.jshintrc');

.resolve

Returns the fully resolve path for the specified config file. Searches the local project first, then the user's home directory.

Params

  • filepath {String}: Filepath to find
  • options {Object}
  • returns {String}: filepath to config file

Example

var fp = config.resolve('.jshintrc');
//=> '/Users/jonschlinkert/dev/config-file/package.json'

.parse

Parse a config file. Same as using config().

Params

  • filename {String}: Name of the file to parse.
  • options {Object}
  • returns {Object}

Example

var data = config.parse('.jshintrc');

Related projects

  • global-modules: The directory used by npm for globally installed npm modules.
  • look-up: Like findup-sync and supports the same features but 20x-40x faster on avg.
  • read-data: Read JSON or YAML files.
  • read-yaml: Very thin wrapper around js-yaml for directly reading in YAML files.

Running tests

Install dev dependencies:

$ npm i -d && npm i -g verb-cli && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

Jon Schlinkert

License

Copyright © 2014-2015 Jon Schlinkert Released under the MIT license.


This file was generated by verb-cli on July 06, 2015.