JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 16064564
  • Score
    100M100P100Q217228F
  • License MIT

find the closest package.json

Package Exports

  • find-root

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (find-root) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

find-root

recursively find the closest package.json

Circle CI

usage

Say you want to check if the directory name of a project matches its module name in package.json:

var path = require('path')
var findRoot = require('find-root')

// from a starting directory, recursively search for the nearest
// directory containing package.json
var root = findRoot('/Users/jden/dev/find-root/tests')
// => '/Users/jden/dev/find-root'

var dirname = path.basename(root)
console.log('is it the same?')
console.log(dirname === require(path.join(root, 'package.json')).name)

api

findRoot: (startingPath : String) => String

Returns the path for the nearest directory to startingPath containing a package.json file, eg /foo/module.

Throws an error if no package.json is found at any level in the startingPath.

installation

$ npm install find-root

running the tests

From package root:

$ npm install
$ npm test

contributors

license

MIT. (c) MMXIII AgileMD http://agilemd.com