Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including find-config-up with all npm packages installed. Try it out:

var findConfigUp = require("find-config-up")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

find-config-up v1.1.1

Resolve your packages configuration from a .*rc or package.json with a given property up the file-tree.

find-config-up

Powered by Immowelt Build Status Dependency Status devDependency Status Renovate enabled semantic-release

Resolve your packages configuration from a .*rc or package.json file with a given property up the file-tree.

Install

$ yarn add find-config-up

API

Getting started

const findConfigUp = require('find-config-up');

(async function() {
  //
  // Tries to find a `.myfancyrc` up the tree and merges it with the defaults,
  // if no file was found it falls back to resolving a `package.json` up the tree
  // with a `my-fancy-package` property defined.
  //
  // If none of the above was successful, the defaults will be returned.
  //
  const config = await findConfigUp({
    rawConfigFileName: '.myfancyrc',
    packageJsonProperty: 'my-fancy-package',
    defaults: {}
  });

  console.log(config);
})()

Options

rawConfigFileName: string (Optional)

The file name of your preffered .rc file, e.g. .babelrc, which should be resolved up the file-system tree.

packageJsonProperty: string

The property name which should be resolved in the package.json files up the file-system tree.

defaults: Object

The defaults which will be recursively merged with the results from the file-system.

cwd: string (Optional)

A custom current working directory, falls back to process.cwd().

Contributing

See the CONTRIBUTING.md file at the root of the repository.

Licensing

See the LICENSE file at the root of the repository.

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free