{"name":"find-root","author":{"name":"jsdnxx"},"version":"1.1.0","description":"find the closest package.json","keywords":["fs","get","find","closest","package","module","base","root"],"main":"index.js","scripts":{"pretest":"standard","test":"mocha"},"repository":{"type":"git","url":"git+ssh://git@github.com/js-n/find-root.git"},"license":"MIT","devDependencies":{"chai":"^4.0.2","mocha":"^3.4.2","moquire":"^1.5.5","standard":"^10.0.2"},"gitHead":"853727496c7846456cee13f3bf9079ba978bc858","bugs":{"url":"https://github.com/js-n/find-root/issues"},"homepage":"https://github.com/js-n/find-root#readme","_id":"find-root@1.1.0","_npmVersion":"5.0.4","_nodeVersion":"8.1.2","_npmUser":{"name":"jsdnxx","email":"jason@denizac.org"},"dist":{"integrity":"sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==","shasum":"abcfc8ba76f708c42a97b3d685b7e9450bfb9ce4","tarball":"http://registry-npm.ywwl.com/find-root/download/find-root-1.1.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIE1hKa5znXkuNBi87U7bO/SmQcwJX+H4SvEYDmXDA4tlAiBTDJIHzuTU7FiLg7jAZNpH3NkrKvC/WwxIzdBsWzk0GA=="}],"size":2589,"noattachment":false,"key":"/find-root/-/find-root-1.1.0.tgz"},"maintainers":[{"name":"jsdnxx","email":"jason@denizac.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/find-root-1.1.0.tgz_1498771558761_0.5412233145907521"},"directories":{},"readme":"# find-root\nrecursively find the closest package.json\n\n[![Build Status](https://travis-ci.org/js-n/find-root.svg?branch=master)](https://travis-ci.org/js-n/find-root)\n\n## usage\nSay you want to check if the directory name of a project matches its\nmodule name in package.json:\n\n```js\nconst path = require('path')\nconst findRoot = require('find-root')\n\n// from a starting directory, recursively search for the nearest\n// directory containing package.json\nconst root = findRoot('/Users/jsdnxx/Code/find-root/tests')\n// => '/Users/jsdnxx/Code/find-root'\n\nconst dirname = path.basename(root)\nconsole.log('is it the same?')\nconsole.log(dirname === require(path.join(root, 'package.json')).name)\n```\n\nYou can also pass in a custom check function (by default, it checks for the\nexistence of `package.json` in a directory). In this example, we traverse up\nto find the root of a git repo:\n```js\nconst fs = require('fs')\n\nconst gitRoot = findRoot('/Users/jsdnxx/Code/find-root/tests', function (dir) {\n  return fs.existsSync(path.resolve(dir, '.git'))\n})\n```\n\n\n## api\n\n### `findRoot: (startingPath : string, check?: (dir: string) => boolean) => string`\n\nReturns the path for the nearest directory to `startingPath` containing\na `package.json` file, eg `/foo/module`.\n\nIf `check` is provided, returns the path for the closest parent directory\nwhere `check` returns true.\n\nThrows an error if no `package.json` is found at any level in the\n`startingPath`.\n\n\n## installation\n```sh\n> npm install find-root\n```\n\n## running the tests\n\nFrom package root:\n```sh\n> npm install\n> npm test\n```\n\n## contributors\n\n- jsdnxx\n\n\n## license\nMIT. (c) 2017 jsdnxx\n","publish_time":1498771558908,"_cnpm_publish_time":1498771558908,"dist-tags":{"latest":"1.1.0"}}