rcfinder

WebJar for rcfinder

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

rcfinder
Last Version

Last Version

0.1.9
Release Date

Release Date

Type

Type

jar
Description

Description

rcfinder
WebJar for rcfinder
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/spalger/rcfinder

Download rcfinder

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/rcfinder/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>rcfinder</artifactId>
    <version>0.1.9</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/rcfinder/
implementation 'org.webjars.npm:rcfinder:0.1.9'
// https://jarcasting.com/artifacts/org.webjars.npm/rcfinder/
implementation ("org.webjars.npm:rcfinder:0.1.9")
'org.webjars.npm:rcfinder:jar:0.1.9'
<dependency org="org.webjars.npm" name="rcfinder" rev="0.1.9">
  <artifact name="rcfinder" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='rcfinder', version='0.1.9')
)
libraryDependencies += "org.webjars.npm" % "rcfinder" % "0.1.9"
[org.webjars.npm/rcfinder "0.1.9"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm : lodash.clonedeep jar [4.3.2,5)

Project Modules

There are no modules declared in this project.

rcfinder

Travis CI

This module provides the file lookup logic for the generally more useful rcloader package.

Find a config file (like .jshintrc) by walking up from a specific directory.

Custom logic can be implemented for loading your config files, and calls to the file system are cached so that you can find files relative to every file in a project without making a ton of unnecessary calls.

install

npm install rcfinder

Use

Create an instance of the RcFinder class, passing it the name of your config file and an object specifying other options.

var RcFinder = require('rcfinder');
var rcFinder = new RcFinder('.jshintrc', {});

Then you can use the finder to look up the proper config file for a directory.

// get the closet .jshintc file for this file
var config = rcFinder.find(__dirname);

If you want to use async file system calls, just specify a callback to find.

rcFinder.find(__dirname, function (err, config) {

});

Config

When creating an instance of the RcFinder class, you can specify options to dictate how the class behaves.

config.loader

A function to call that will load a given path. Once the path for a config file is determined, this will be called with that path as it's only argument and it should return a proper value.

The default loader is:

function loader(path) {
  return JSON.parse(fs.readFileSync(path));
}

To make your loader async, simply ask for second argument which will be set to a node-style callback. You can also ask for a simple async JSON loader by setting loader: equal to 'async'.

NOTE: You must call .find() with a callback if your loader is async.

Versions

Version
0.1.9