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

manis

v0.3.5

Published

Find and read your configuration files recursively

Downloads

1,302

Readme

Manis

For build system plugins that need to fetch relative config files (like .fecsrc).

Build Status NPM version Coverage Status DevDependencies

Install

npm install manis

Usage

Using strip-json-comments

var Manis = require('manis');
var stripJSONComments = require('strip-json-comments');

var loader = function (text) {
    return JSON.parse(stripJSONComments(text));
};

var manis = new Manis({
    files: [
        {
            // just for example, it should be loaded as yaml in fact.
            name: '.eslintrc',
            get: function (json) {
                return {eslint: json};
            }
        },
        '.fecsrc',
        {
            name: 'package.json',
            get: function (json) {
                return json.fecs || {};
            }
        }
    ],
    loader: loader
});

var options = manis.from('path/to/file.js');

// do something cool with options

NOTICE: the default loader strip comment after [email protected].

Loading .yml with js-yaml

var yaml = require('js-yaml');

var Manis = require('manis');

var loader = function (text) {
    return yaml.load(text);
};

var manis = new Manis('.travis.yml', {loader: loader});

var options = manis.from('path/to/file.js');

// do something cool with options

NOTICE: the default loader used js-yaml to load YAML and JSON content after [email protected].

With defaults

var Manis = require('manis');

var manis = new Manis({
    files: [
        '.fecsrc',
        {
            name: 'package.json',
            get: 'fecs'
        }
    ]
});

manis.setDefault('default/path/to/config/fecs.json');

var options = manis.from('path/to/file.js');

// do something cool with options

User config

var Manis = require('manis');

var manis = new Manis({
    files: [
        '.fecsrc',
        {
            name: 'package.json',
            get: 'fecs'
        }
    ]
});

manis.setDefault('default/path/to/config/fecs.json');

// will find `~/.fecsrc`
manis.setUserConfig();

var options = manis.from('path/to/file.js');

// do something cool with options

Within a gulp plugin

var Manis = require('manis');
var map = require('map-stream');

module.exports = function MyGulpPlugin(options) {
    var manis = new Manis('.fecsrc', options);

    return map(function (file, cb) {

        // get the options for this file specifically
        var options = manis.from(file.path);

        // do something cool

        // send the file along
        cb(null, file);

    });
};

API

new Manis(string fileName[, Object options]);

new Manis(string[] fileNames[, Object options]);

new Manis(Object[] finderOptioins[, Object options]);

new Manis(Object options);

void Manis#setDefault(Object defaultValue);

void Manis#setDefault(string filePath[, Object finderOptions]);

void Manis#setUserConfig();

void Manis#setUserConfig(Object userConfig);

void Manis#setUserConfig(string userConfigPathOrName[, Object finderOptions]);

Object Manis#from(string path);

Manis.yaml;

Alias for js-yaml module.

Object Manis.loader;

The default loader, parse JSON or YAML content with js-yaml.

Object Manis#from(string path);

options

  • files, Array or string, items could be string or Object.

  • loader, Function,parser for config content.

  • lookup, Boolean, Find all up-level config files. default is true.

  • merge, Boolean, Merge all config objects. default is true.

  • cache, Boolean, Cache config files. default is true.

  • rootName, String, The name of flag when enableRoot set to true. default is 'root'.

  • enableRoot, Boolean, Enable the root flag to stop lookup in up-level directory. default is false.

  • stopper, Function, the predicate for stopping search. default is null.

finderOptions

  • name, string, the file name to be searched.

  • loader, Funtion, the same as options.loader above;

  • stopper, Function, the predicate for stopping search.

  • get, string or Function, the field name to retrieve from config object.

  • cache, Boolean, Cache config files. default is true.