{"_id":"root-require","_rev":"757009","name":"root-require","description":"For use in tests only! require() using a relative path from the root directory of the present module","dist-tags":{"latest":"0.3.1"},"maintainers":[{"name":"balderdashy","email":"mike@balderdash.co"}],"time":{"modified":"2024-06-27T03:47:40.000Z","created":"2014-01-03T14:46:00.425Z","0.3.1":"2014-01-15T02:03:28.955Z","0.3.0":"2014-01-15T01:59:40.554Z","0.2.0":"2014-01-03T16:23:26.666Z","0.1.0":"2014-01-03T15:14:29.278Z","0.0.4":"2014-01-03T15:13:14.523Z","0.0.3":"2014-01-03T14:53:44.374Z","0.0.2":"2014-01-03T14:53:10.568Z","0.0.1":"2014-01-03T14:46:00.425Z"},"users":{"leroysalih":true},"author":{"name":"Mike McNeil"},"repository":{"type":"git","url":"git://github.com/mikermcneil/root-require.git"},"versions":{"0.3.1":{"name":"root-require","version":"0.3.1","description":"For use in tests only! require() using a relative path from the root directory of the present module","main":"index.js","dependencies":{"packpath":"~0.1.0"},"devDependencies":{},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com/mikermcneil/root-require.git"},"keywords":["root","require","relative"],"author":{"name":"Mike McNeil"},"license":"MIT","bugs":{"url":"https://github.com/mikermcneil/root-require/issues"},"homepage":"https://github.com/mikermcneil/root-require","readmeFilename":"README.md","_id":"root-require@0.3.1","dist":{"shasum":"95e1554d63cc869a2abde3e3bfc9bbaaa1edacd3","tarball":"http://registry-npm.ywwl.com/root-require/download/root-require-0.3.1.tgz","integrity":"sha512-ELHRna2cNq2HK6BxBGgyLtNCb4ltsQc0Y03ihTlb0VGR4f3zTVZ3soiu215Oqxfwncd5teOEk3sQkD8uHQBZBw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBn+x7BiOQZs1TUmJlc/7XmgUDp2JjBmmnd3H0y1VXPFAiBUsIp1Q0w8UqhUg39D4UvOQQPTkrGHC/iDfNL0hLFKrA=="}],"size":2802,"noattachment":false,"key":"/root-require/-/root-require-0.3.1.tgz"},"_from":".","_npmVersion":"1.3.17","_npmUser":{"name":"balderdashy","email":"mike@balderdash.co"},"maintainers":[{"name":"balderdashy","email":"mike@balderdash.co"}],"directories":{},"publish_time":1389751408955,"_cnpm_publish_time":1389751408955},"0.3.0":{"name":"root-require","version":"0.3.0","description":"For use in tests only! require() using a relative path from the root directory of the present module","main":"index.js","dependencies":{"packpath":"~0.1.0"},"devDependencies":{},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com/mikermcneil/root-require.git"},"keywords":["root","require","relative"],"author":{"name":"Mike McNeil"},"license":"MIT","bugs":{"url":"https://github.com/mikermcneil/root-require/issues"},"homepage":"https://github.com/mikermcneil/root-require","readmeFilename":"README.md","_id":"root-require@0.3.0","dist":{"shasum":"fce009872d7ea6fb5ca282a8f783155098138370","tarball":"http://registry-npm.ywwl.com/root-require/download/root-require-0.3.0.tgz","integrity":"sha512-DZnLaJESWcr4VKHK8ijUAV2aSM9UtfcUxnsEk6fuY6nXKgDI/Z9Z9TZKrDx5x+JBb/LhFZ21jK/WXPWM7MQE8Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCqgBT+Pu3w6iYSGQL8CRNv0tvaZwp/iEJ5q3hvmcwItwIhAL6rHBlIJHkoJRi4JvOxpzGhEZPoMZNlZHJ9KUUl+ONb"}],"size":2647,"noattachment":false,"key":"/root-require/-/root-require-0.3.0.tgz"},"_from":".","_npmVersion":"1.3.17","_npmUser":{"name":"balderdashy","email":"mike@balderdash.co"},"maintainers":[{"name":"balderdashy","email":"mike@balderdash.co"}],"directories":{},"publish_time":1389751180554,"_cnpm_publish_time":1389751180554},"0.2.0":{"name":"root-require","version":"0.2.0","description":"require() using a relative path from the root directory of the present module","main":"index.js","dependencies":{"packpath":"~0.1.0"},"devDependencies":{},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com/mikermcneil/root-require.git"},"keywords":["root","require","relative"],"author":{"name":"Mike McNeil"},"license":"MIT","bugs":{"url":"https://github.com/mikermcneil/root-require/issues"},"homepage":"https://github.com/mikermcneil/root-require","readmeFilename":"README.md","_id":"root-require@0.2.0","dist":{"shasum":"7e74337f55d747ee9c30c24d262d10a2b6dd3853","tarball":"http://registry-npm.ywwl.com/root-require/download/root-require-0.2.0.tgz","integrity":"sha512-qti/wqI9nRg3dy15r3TizNyHVOg9bONNMaceNyMyH+gw//fazGBl+yzLwmBWDmFu19xuaKFwYDcVSpFPGDTuFw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFoZSyhRklRX0bD82RRwEWNzXBWactTkin/UgbtVAmMoAiAmg1wGmPeVQnW2SHlbeP7gPBa/LSwHLOPKn5jjZdM/xg=="}],"size":2445,"noattachment":false,"key":"/root-require/-/root-require-0.2.0.tgz"},"_from":".","_npmVersion":"1.3.17","_npmUser":{"name":"balderdashy","email":"mike@balderdash.co"},"maintainers":[{"name":"balderdashy","email":"mike@balderdash.co"}],"directories":{},"publish_time":1388766206666,"_cnpm_publish_time":1388766206666},"0.1.0":{"name":"root-require","version":"0.1.0","description":"require() using a relative path from the root directory of the present module","main":"index.js","dependencies":{"packpath":"~0.1.0"},"devDependencies":{},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com/mikermcneil/root-require.git"},"keywords":["root","require","relative"],"author":{"name":"Mike McNeil"},"license":"MIT","bugs":{"url":"https://github.com/mikermcneil/root-require/issues"},"homepage":"https://github.com/mikermcneil/root-require","readmeFilename":"README.md","_id":"root-require@0.1.0","dist":{"shasum":"94330f41c4723357d4ad763375b0c9759ec25dab","tarball":"http://registry-npm.ywwl.com/root-require/download/root-require-0.1.0.tgz","integrity":"sha512-c2DhKItZjNYC9zviLUW0w9wPFsrhUWvdlnqFgp+xIBTqesGw6SLpBcgqxPjjkVKo/ENR93rTaXmvwbp1xrwumQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCz4Q1d88/uwI2aw3eIuxmTPuWkyt7Rgas71L1BmqngxwIhAMAPD/v7crtOYDjRvt532PIifL7DcA5+ZvWJv1dQT+WH"}],"size":2064,"noattachment":false,"key":"/root-require/-/root-require-0.1.0.tgz"},"_from":".","_npmVersion":"1.3.17","_npmUser":{"name":"balderdashy","email":"mike@balderdash.co"},"maintainers":[{"name":"balderdashy","email":"mike@balderdash.co"}],"directories":{},"publish_time":1388762069278,"_cnpm_publish_time":1388762069278},"0.0.4":{"name":"root-require","version":"0.0.4","description":"require() using a relative path from the root directory of the present module","main":"index.js","dependencies":{"packpath":"~0.1.0"},"devDependencies":{},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com/mikermcneil/root-require.git"},"keywords":["root","require","relative"],"author":{"name":"Mike McNeil"},"license":"MIT","bugs":{"url":"https://github.com/mikermcneil/root-require/issues"},"homepage":"https://github.com/mikermcneil/root-require","readmeFilename":"README.md","_id":"root-require@0.0.4","dist":{"shasum":"920b0ab157ec7af18acdc7c32c59d69669a1eadc","tarball":"http://registry-npm.ywwl.com/root-require/download/root-require-0.0.4.tgz","integrity":"sha512-t0vewnAGzNoBmhtJMMu4rP+gcfzThV5Efph478cnfsWUFGCr21EA/sKN3SGRa8QeRtSP83A03vcu0XaRAB5WcQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDxcdMDCf70vcUvQa7B/Eg8YHXaFex+v4wTezDbYWE4vwIgSQp7hDNRptN7cEUCsD3SHPvjAzQZLrBL9OtKpvdMJng="}],"size":2104,"noattachment":false,"key":"/root-require/-/root-require-0.0.4.tgz"},"_from":".","_npmVersion":"1.3.17","_npmUser":{"name":"balderdashy","email":"mike@balderdash.co"},"maintainers":[{"name":"balderdashy","email":"mike@balderdash.co"}],"directories":{},"publish_time":1388761994523,"_cnpm_publish_time":1388761994523},"0.0.3":{"name":"root-require","version":"0.0.3","description":"require() using a relative path from the root directory of the present module","main":"index.js","dependencies":{"packpath":"~0.1.0"},"devDependencies":{},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com/mikermcneil/root-require.git"},"keywords":["root","require","relative"],"author":{"name":"Mike McNeil"},"license":"MIT","bugs":{"url":"https://github.com/mikermcneil/root-require/issues"},"homepage":"https://github.com/mikermcneil/root-require","readmeFilename":"README.md","_id":"root-require@0.0.3","dist":{"shasum":"6591f6526bf5b0c02dbc56e203e7d88f6d31454a","tarball":"http://registry-npm.ywwl.com/root-require/download/root-require-0.0.3.tgz","integrity":"sha512-YSmBE2vWDCBpoEqLZiCN03VIr+M+KfJOtIGiX1SNEGkHSS/VFHIoPRjh40qjmrGSgQ/p7SdWhPB8JX7B8BubJg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC1sSUdxQmCo79wERM/thboUJmv+ssFXb+VKDtstypauwIgA83BKFnErHhnHeEjZe/nplznpRMrIVqI2jaG9yGpU4k="}],"size":1756,"noattachment":false,"key":"/root-require/-/root-require-0.0.3.tgz"},"_from":".","_npmVersion":"1.3.17","_npmUser":{"name":"balderdashy","email":"mike@balderdash.co"},"maintainers":[{"name":"balderdashy","email":"mike@balderdash.co"}],"directories":{},"publish_time":1388760824374,"_cnpm_publish_time":1388760824374},"0.0.2":{"name":"root-require","version":"0.0.2","description":"require() using a relative path from the root directory of the present module","main":"index.js","dependencies":{"packpath":"~0.1.0"},"devDependencies":{},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com/mikermcneil/root-require.git"},"keywords":["root","require","relative"],"author":{"name":"Mike McNeil"},"license":"MIT","bugs":{"url":"https://github.com/mikermcneil/root-require/issues"},"homepage":"https://github.com/mikermcneil/root-require","readmeFilename":"README.md","_id":"root-require@0.0.2","dist":{"shasum":"ca51c866253c01f04f9ce841994f8de7fda3e775","tarball":"http://registry-npm.ywwl.com/root-require/download/root-require-0.0.2.tgz","integrity":"sha512-V/eWg8gbjzbcbtQtbj5EnyWNslDRy86mn5RhPWF+QF/VmMdpTfaNrNwI+fIg9ZBgWH9T5YPJkCXd9KwO8PS3CA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBSGloM2y/f9jOVoF87PzMdpndfz4QfJEogFSW81nTy9AiAbDHnDNpCNe8x6oSry0vRBaJjaLUAoWioWZMX++FgUyg=="}],"size":1754,"noattachment":false,"key":"/root-require/-/root-require-0.0.2.tgz"},"_from":".","_npmVersion":"1.3.17","_npmUser":{"name":"balderdashy","email":"mike@balderdash.co"},"maintainers":[{"name":"balderdashy","email":"mike@balderdash.co"}],"directories":{},"publish_time":1388760790568,"_cnpm_publish_time":1388760790568},"0.0.1":{"name":"root-require","version":"0.0.1","description":"require() using a relative path from the root directory of the present module","main":"index.js","dependencies":{"packpath":"~0.1.0"},"devDependencies":{},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git://github.com/mikermcneil/root-require.git"},"keywords":["root","require","relative"],"author":{"name":"Mike McNeil"},"license":"MIT","bugs":{"url":"https://github.com/mikermcneil/root-require/issues"},"homepage":"https://github.com/mikermcneil/root-require","readmeFilename":"README.md","_id":"root-require@0.0.1","dist":{"shasum":"7ad66bf1ab55705dcc25c981f477b7f519c67101","tarball":"http://registry-npm.ywwl.com/root-require/download/root-require-0.0.1.tgz","integrity":"sha512-T2I9xF9SypLXj5Ca82X/5kXUIgyN89SuBg8Fd1cOxBcT05nI82dxLYkmb/7jupIDjqY/VoxuReo+h66E2yBTDw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDRx5CbCTHT3WGgOe8VaXODNjOiJN4l0Q0sXO6jK3Z1kAIhAIrS7JI5auG7xNQN1HDuj7vxZVuHx4MPbVX1+MKA0DPw"}],"size":1755,"noattachment":false,"key":"/root-require/-/root-require-0.0.1.tgz"},"_from":".","_npmVersion":"1.3.17","_npmUser":{"name":"balderdashy","email":"mike@balderdash.co"},"maintainers":[{"name":"balderdashy","email":"mike@balderdash.co"}],"directories":{},"publish_time":1388760360425,"_cnpm_publish_time":1388760360425}},"readme":"root-require\n============\n\n\na more convenient require method for running **TESTS ONLY**.\n\n> ### WARNING:\n> THIS MODULE PROBABLY DOES NOT WORK IN THE WAY YOU EXPECT IT TO WORK ALL THE TIME.\n> I REPEAT: IT HAS DIFFERENT BEHAVIOR BASED ON HOW IT'S BROUGHT IN AS A DEPENDENCY THAT WILL CAUSE YOU HEADACHES.  ESPECIALLY IF YOU USE IT IN TWO MODULES WHICH DEPEND ON ONE ANOTHER.  (this is because of the way npm optimizes dependencies, and this module doesn't address that, since it's for testing only.).\n>\n> That said, as long as you use this module as a **DEV DEPDENDENCY**, everything _should_ work as expected.  Sorry for the capslock.\n> ~Mike\n\n\n## How it do\nThis lets you `require()` using a relative path from the root directory of the present module.\n\n> Keep in mind `require()` is synchronous.  And this library is not any more efficient-- (it uses `fs.*Sync` methods)\n> Just like when you use `require()`, you should be fine as long as you're doing this at the top of your file outside of any function declarations.\n\n\n\n## Usage\n\nJust once:\n```javascript\nvar Sails = require('root-require')('lib/app');\n```\n\nMore than once:\n```javascript\nvar rootRequire = require('root-require');\n\nvar Sails = rootRequire('lib/app');\nvar Router = rootRequire('lib/router');\nvar MiddlewareLibrary = rootRequire('lib/middleware');\n```\n\n\n\n## Why is this a good thing?\n\nIt's easier to reason about the structure of your module when the paths are consistent.  The structure of your project becomes more declarative- dependencies are consistently referenced, irrespective of the user file's home in the directory structure.\n\n#### Problems w/ `require()`\n\n1. When you move a dependency file (_A<sub>x</sub>_) required by multiple files (_B<sub>i</sub>_), you have to find/replace the all references to _A<sub>x</sub>_.  This is normally hard, because the argument to the `require(...)` function depends on where the user file (_B<sub>i</sub>_) is located.\n2. When you move a file (_B<sub>x</sub>_) which depends on another file (_A<sub>x</sub>_), you normally have to update the `require()` call in _B<sub>x</sub>_ to reflect the new relative path from _B<sub>x</sub>_ to _A<sub>x</sub>_.\n\ne.g. Consider trying to change the path to `giggle.js` in an automated way:\n\nhard \n```javascript\n// foo.js\nvar Giggle = require('./wiggle/sniggle/giggle');\n\n// bar.js\nvar Giggle = require('../../../../../wiggle/sniggle/giggle');\n\n// baz.js\nvar Giggle = require('../../../../wiggle/sniggle/giggle');\n\n// 20 more files like this, 100 other files like `giggle.js`\n```\n\neasy\n```javascript\n// foo.js\nvar Giggle = require('root-require')('lib/wiggle/sniggle/giggle');\n\n// bar.js\nvar Giggle = require('root-require')('lib/wiggle/sniggle/giggle');\n\n// baz.js\nvar Giggle = require('root-require')('lib/wiggle/sniggle/giggle');\n\n// 20 more files like this, 100 other files like `giggle.js`\n```\n\n\n\n\n\n\n## Credit where credit is due\nThis module is literally a 3-line wrapper around the awesome `packpath` module (https://github.com/jprichardson/node-packpath).  I just made this for convenience/ so I could have it in one line because I always forget how `path.join` works w/ Windows and all that.\n\n\n## License\n\nMIT, c. 2014 Mike McNeil\n","_attachments":{},"readmeFilename":"README.md","homepage":"https://github.com/mikermcneil/root-require","bugs":{"url":"https://github.com/mikermcneil/root-require/issues"},"license":"MIT"}