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

configurations

v3.0.0

Published

manages multiple, competing configurations

Downloads

1,301

Readme

configurations Build Status

NPM

NPM

Loads configuration files depending on the environment, the users individual configuration, additional configuration files that are explicitly defined and CLI parameters.

Interface

configuration#load(baseDir, additionalParameters)

Creates a configurations hash out of several overlapping configuration files.

  • baseDir the directory configurations are loaded from
  • additionalParameters optional additional Parameters e.g. from cli arguments

Logic

Default Configuration

The config file default.(js|json) is always loaded and is the base configuration.

Environment Configuration

The environment is used to load an additional configurations file. Naming convention is {environment}.(js|json). The environment configuration is optional.

User Configuration

For local development an configuration individual for every developer is useful. Will be only loaded if the environment is development. Naming convention is user.{userName}.(js|json). The user configuration is optional.

Additional parameters

Additonal parameters can be specified via a options hash that will be merged into the configuration. cli arguments are a possible source.

External optional additional Configuration

Via the parameters hash the path to an additonal configurations file can be specified. The key for the options hash os externalconfig.

Example

default.js

module.exports = {
    foo: 'bar',
    bax: 'baz',
    spam: 'eggs'
};

/foo/bar/optionalConfig.js

module.exports = {
    spam: 'eggs222'
};

Call

var path = require('path');
var c = require('configurations');

var configuration = c.load(path.join(__dirname, '/config'), {
  bax: 'bazzzz',
  externalconfig: '/foo/bar/optionalConfig.js'
});

Result

{
    foo: 'bar',
    bax: 'bazzzz',
    spam: 'eggs222'
}

Example 2

The file example/example.js contains the following content:

var configuration = configurations.load(path.join(__dirname, '/config'), {
    externalconfig: path.join(__dirname, 'config', 'optional.js'),
    foo: 'foo-cli'
});

Run it with the following parameters:

#1

$ NODE_ENV=development node example/example.js

result:

{ "a": "b", "foo": "foo-cli", "bax": "baz-development", "spam": "eggs2" }

#2

$ NODE_ENV=production node example/example.js

result:

{ "a": "b", "foo": "foo-cli", "bax": "baz-production", "spam": "eggs2" }

#3

$ NODE_ENV=foo node example/example.js

result:

{ "a": "b", "foo": "foo-cli", "bax": "baz", "spam": "eggs2" }