{"name":"resolve-dependency-path","version":"4.0.1","keywords":["dependency","filepath","module"],"author":{"name":"Joel Kemp","email":"joel@mrjoelkemp.com"},"license":"MIT","_id":"resolve-dependency-path@4.0.1","maintainers":[{"name":"pahen","email":"patrik.henningsson@gmail.com"},{"name":"mrjoelkemp","email":"mrjoelkemp@gmail.com"},{"name":"xhmikosr","email":"xhmikosr@gmail.com"}],"homepage":"https://github.com/dependents/node-resolve-dependency-path","bugs":{"url":"https://github.com/dependents/node-resolve-dependency-path/issues"},"xo":{"rules":{"curly":["error","multi-line"],"comma-dangle":["error","never"],"arrow-body-style":"off","operator-linebreak":["error","after"],"capitalized-comments":"off","object-curly-spacing":["error","always"],"unicorn/prefer-module":"off","space-before-function-paren":["error","never"],"unicorn/prefer-string-slice":"off","unicorn/prefer-node-protocol":"off","unicorn/prevent-abbreviations":"off","unicorn/prefer-top-level-await":"off","unicorn/no-anonymous-default-export":"off"},"space":true,"ignores":["test/fixtures/*"]},"dist":{"shasum":"1b9d43e5b62384301e26d040b9fce61ee5db60bd","tarball":"http://registry-npm.ywwl.com/resolve-dependency-path/download/resolve-dependency-path-4.0.1.tgz","fileCount":4,"integrity":"sha512-YQftIIC4vzO9UMhO/sCgXukNyiwVRCVaxiWskCBy7Zpqkplm8kTAISZ8O1MoKW1ca6xzgLUBjZTcDgypXvXxiQ==","signatures":[{"sig":"MEQCICq2Cd90YZk+ucnzTJ/Vt1Ns4S0tkv4uYmZMRSyyDQBuAiAvF8HqFXtM3kCTmU87CVU95LWoPszuF6t/Yl2+K825KA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":6849,"size":2819,"noattachment":false,"key":"/resolve-dependency-path/-/resolve-dependency-path-4.0.1.tgz"},"main":"index.js","engines":{"node":">=18"},"gitHead":"7b0e06ae2b0c47ae0fc3db12f372fc12a5dda3dd","scripts":{"fix":"xo --fix","lint":"xo","test":"npm run lint && npm run mocha","mocha":"mocha","test:ci":"c8 npm run mocha"},"_npmUser":{"name":"xhmikosr","email":"xhmikosr@gmail.com"},"repository":{"url":"git+https://github.com/dependents/node-resolve-dependency-path.git","type":"git"},"_npmVersion":"10.8.2","description":"Convert a dependency path into a filepath","directories":{},"_nodeVersion":"20.18.2","_hasShrinkwrap":false,"devDependencies":{"c8":"^10.1.3","xo":"^0.60.0","mocha":"^11.1.0"},"_npmOperationalInternal":{"tmp":"tmp/resolve-dependency-path_4.0.1_1738415211271_0.06018840337621567","host":"s3://npm-registry-packages-npm-production"},"readme":"# resolve-dependency-path\n\n[![CI](https://img.shields.io/github/actions/workflow/status/dependents/node-resolve-dependency-path/ci.yml?branch=main&label=CI&logo=github)](https://github.com/dependents/node-resolve-dependency-path/actions/workflows/ci.yml?query=branch%3Amain)\n[![npm version](https://img.shields.io/npm/v/resolve-dependency-path?logo=npm&logoColor=fff)](https://www.npmjs.com/package/resolve-dependency-path)\n[![npm downloads](https://img.shields.io/npm/dm/resolve-dependency-path)](https://www.npmjs.com/package/resolve-dependency-path)\n\n> Convert a dependency path into a filepath\n\n```sh\nnpm install resolve-dependency-path\n```\n\n## Usage\n\n### ESM\n\n```js\nimport resolvePath from 'resolve-dependency-path';\n\nconst resolved = resolvePath({\n  dependency: './foobar',\n  filename: 'path/to/file/containing/dependency.js',\n  directory: 'path/to/all/files'\n});\n```\n\n### CommonJS\n\n```js\nconst { default: resolvePath } = require('resolve-dependency-path');\n```\n\n### Options\n\n| Option | Type | Required | Description |\n|---|---|---|---|\n| `dependency` | `string` | Yes | The dependency specifier (e.g. the argument to `require()`) |\n| `filename` | `string` | Yes | Absolute or relative path of the file that contains the dependency |\n| `directory` | `string` | Yes | Root directory used to resolve non-relative dependencies |\n\n## Example\n\nIf you have a file like:\n\n*myapp/foo.js*\n\n```js\nrequire('./bar');\n```\n\nThen if you want to open the file associated with the dependency, you need to resolve `./bar` onto the filesystem.\n\nSince `./bar` is a relative path, it should be resolved relative to `foo.js`,\nmore specifically the directory containing `foo.js`, `myapp/`. This resolution would yield\n`myapp/bar.js`.\n\nThis is why the `filename` attribute is required to use this library.\n\nIf you have a non-relative dependency path like:\n\n*myapp/foo.js*\n\n```js\ndefine([\n  'bar'\n], function(bar) {\n\n});\n```\n\nThen `bar` is relative to the root of all files, `myapp`. The resolution would yield\n`myapp/bar.js`.\n\nA more complex example with subdirectories:\n\n*myapp/feature1/foo.js*\n\n```js\ndefine([\n  'feature2/bar'\n], function(bar) {\n\n});\n```\n\nThe dependency `feature2/bar` is relative to the root of all files, `myapp`, *not* the file `foo.js`.\n\nThis is why the `directory` attribute is required to use this library.\n\n## License\n\n[MIT](LICENSE)\n","publish_time":1738415211506,"_cnpm_publish_time":1738415211506,"dist-tags":{"latest":"5.0.0"}}