{"_id":"@antora/user-require-helper","_rev":"3-b3b9dec07add2fc1a0f10d984c121110","name":"@antora/user-require-helper","dist-tags":{"latest":"3.0.0"},"versions":{"1.0.0":{"name":"@antora/user-require-helper","version":"1.0.0","keywords":["require","resolve","user","module","path","absolute","relative","cwd","pwd","home"],"author":{"url":"https://opendevise.com","name":"OpenDevise Inc."},"license":"MPL-2.0","_id":"@antora/user-require-helper@1.0.0","maintainers":[{"name":"mojavelinux","email":"dan.j.allen@gmail.com"},{"name":"graphitefriction","email":"sarah@opendevise.com"}],"contributors":[{"name":"Dan Allen","email":"dan@opendevise.com"}],"homepage":"https://gitlab.com/antora/user-require-helper#readme","bugs":{"url":"https://gitlab.com/antora/user-require-helper/issues"},"nyc":{"cache":true,"include":["lib/**/*.js"],"cacheDir":"node_modules/.cache/nyc","reporter":["lcov"]},"dist":{"shasum":"db11f9050933a728b4e449afc65444286839b080","tarball":"https://registry.npmjs.org/@antora/user-require-helper/-/user-require-helper-1.0.0.tgz","fileCount":5,"integrity":"sha512-Wbkzztd5AAhnIWwSn0Oebf3aFNnDXzUakQ0CN5kuBSSRlAtX4YfdrAFk9L3a7ZeCn3ogbm68RfSwd3bGvX8uQQ==","signatures":[{"sig":"MEUCIEErEtAflIgFzEVevulNB90BBZs8TNOzGK9Zh3syIfYeAiEA9ak9W7gWW6fKBww4xNRFH5kD9wm4ylxAR5Ho8HmLwSY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":28655,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg7BkNCRA9TVsSAnZWagAAOJ0QAJ9ijk4eKs1r1ALI5kPZ\njyOl7edv9Hi65iVyhu8Xfiv1O+ehfNjyxXRcOPZmzXUyz40h/ECwp35zX9jV\nxOP9yzdBEIy1oU3AqP6B1pRwOSojBdkQlO+Mz87mUYcNoHqQqrZ6iMIqb3l/\ndGfT0DrEytmTSBBGdzhmQlDbsYn3v45Qcqytd4w5Jm+myIbiyMJ/Qn5eAyo2\njb5F2e/YHoh2SwrMf4gB1mTyOV0iJekMU5gkALl950RdWwBbFDKBM/g6txZs\naiR/p12FqdBzTmaXu8bg8jTcIIiCAtBmfUiLpt4q8yBnxKMQpGT+Ymrs9gFc\nftW46p81mNqNLkrszRupocLhoxirMUVt8wz1KOlwhH408DdYXTxu1fEdodkk\no/lFc3uZoRkOv6rrALiTm7dS2kXg0QRHB8Ql7wxzqDp+z4Fyd5MC8QT56noT\n4k5HTc3YEZMaf+qVFE/icEbFONqJAbysho6LmPLhKz8Ta7lR2YxXJIBahTUt\nciwGGRJIFbDYdAW0XSXunlAIcJC7LVPR6Hx1fMWLarbNSr7/MO0XQ9q+RIxT\n/TOgF2VV0t8LSRc7bQiLb+YDnps5neqYhZ4mxRW3rlBPoKLC+qLhNDLwcR6X\n4jsyPscnNvtJqooNOLMk0wf5kwXRCSdeyJ0DFi2qTfqBwuRQWi96pL0FuYPt\nvzXl\r\n=+akF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"lib/index.js","engines":{"node":">=10.17.0"},"gitHead":"f091a3a35a62eff88aab904144668b68aad5efbd","scripts":{"cov":"nyc _mocha test","lint":"eslint \"{lib,npm,test}/**/*.js\"","test":"_mocha test","format":"prettier-eslint --write \"`pwd`/{lib,npm,test}/**/*.js\""},"_npmUser":{"name":"mojavelinux","email":"dan.j.allen@gmail.com"},"repository":{"url":"git+https://gitlab.com/antora/user-require-helper.git","type":"git"},"_npmVersion":"6.14.12","description":"A helper function to resolve a module name or path in relation to the specified context and require it.","directories":{},"_nodeVersion":"10.24.1","dependencies":{"@antora/expand-path-helper":"~1.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"nyc":"~15.1","chai":"~4.3","mocha":"~8.4","eslint":"~7.30","clear-module":"~4.1","eslint-plugin-node":"~11.1","prettier-eslint-cli":"~5.0","eslint-plugin-import":"~2.23","eslint-plugin-promise":"~4.3","eslint-config-standard":"~16.0"},"_npmOperationalInternal":{"tmp":"tmp/user-require-helper_1.0.0_1626085645406_0.4392168546766262","host":"s3://npm-registry-packages"}},"2.0.0":{"name":"@antora/user-require-helper","version":"2.0.0","keywords":["require","resolve","user","module","path","absolute","relative","cwd","pwd","home"],"author":{"url":"https://opendevise.com","name":"OpenDevise Inc."},"license":"MPL-2.0","_id":"@antora/user-require-helper@2.0.0","maintainers":[{"name":"mojavelinux","email":"dan.j.allen@gmail.com"},{"name":"graphitefriction","email":"sarah@opendevise.com"}],"contributors":[{"name":"Dan Allen","email":"dan@opendevise.com"}],"homepage":"https://gitlab.com/antora/user-require-helper#readme","bugs":{"url":"https://gitlab.com/antora/user-require-helper/issues"},"nyc":{"cache":true,"include":["lib/**/*.js"],"cacheDir":"node_modules/.cache/nyc","reporter":["lcov"]},"dist":{"shasum":"7ba08253989cee86c4877a909278013f7fd383af","tarball":"https://registry.npmjs.org/@antora/user-require-helper/-/user-require-helper-2.0.0.tgz","fileCount":5,"integrity":"sha512-5fMfBZfw4zLoFdDAPMQX6Frik90uvfD8rXOA4UpXPOUikkX4uT1Rk6m0/4oi8oS3fcjiIl0k/7Nc+eTxW5TcQQ==","signatures":[{"sig":"MEQCICxaponjAba/3jIgiQraHi1scW9sneIYdxaLmA5vlmv0AiBrF1KXyYclCnK3lSxqF2gNaDTWz0Jx1eHeaWIQSUMZFA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":29406,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg8pJYCRA9TVsSAnZWagAAOZAQAI+oRcFxurNaIvMsvb82\nMSGa0dRHnJs/QD/+eyw7ya+rx+VpFNUTzlTeQJdnLojbTGIWXaczEyghS5S6\nxj7ZunKLCOl738Wzuo26S9fjlMCE6mH5H6aJU1AXWKcmehR8EXAO2E4MuT4H\nb395gYsle8tFOtvaGk0x7MQCz8B7V81tSLL9cH6NDgZRHPjgEnZ06pH1uCwG\natedHlQwUf3tXRO4w4m76LHtNNbkoBD6sUETKzoliAI9btvuQiCA3VH136nX\n81Yzr9IEh77Dy3Ilj5Kp8xgTgOHy7tUH2+ymTsvFBHxroWE79377c5+OEmYU\nyLiSM3dRnHIGHjEQF99HZh9IVb5GFvCyFZ9TOkA08FpjhapS3OFwpEkvaqEJ\nwYdx1n+Ux3ge9CPLz8ONry04XFBqIsDlWwN5wCn6fFPqfIP3+6qiksUMO5PI\nUWE6ADWsOqh11j3UrHUqzHyAuxUl7bb5haT7XS1qimZcsFNvUo6/QDCGjv7F\nwKo8wglWTAJEBL932TKZu9vek5aEaZHJFsRPLRYIUdi+8xi+myTmhy9y9ZBN\nUXfaujPPze6Gc/FPMn5fK6W5bGLlj/+S5HPSF8SMOC3aYXqAagXWI6GUkmQm\nvX9fZMPiYwYt2LQJTJg0FXNWWilYqoGZvEk4WQk9MLvx4fQouvKH6NjAPpob\nTPMN\r\n=XUH+\r\n-----END PGP SIGNATURE-----\r\n"},"main":"lib/index.js","engines":{"node":">=10.17.0"},"gitHead":"94c65261341b982e57e11ad4b5f1f94904ca22fc","scripts":{"cov":"nyc _mocha test","lint":"eslint \"{lib,npm,test}/**/*.js\"","test":"_mocha test","format":"prettier-eslint --write \"`pwd`/{lib,npm,test}/**/*.js\""},"_npmUser":{"name":"mojavelinux","email":"dan.j.allen@gmail.com"},"repository":{"url":"git+https://gitlab.com/antora/user-require-helper.git","type":"git"},"_npmVersion":"6.14.12","description":"A helper function to resolve a module name or path in relation to the specified context and require it.","directories":{},"_nodeVersion":"10.24.1","dependencies":{"@antora/expand-path-helper":"~2.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"nyc":"~15.1","chai":"~4.3","mocha":"~8.4","eslint":"~7.30","clear-module":"~4.1","eslint-plugin-node":"~11.1","prettier-eslint-cli":"~5.0","eslint-plugin-import":"~2.23","eslint-plugin-promise":"~5.1","eslint-config-standard":"~16.0"},"_npmOperationalInternal":{"tmp":"tmp/user-require-helper_2.0.0_1626509912257_0.4112963922787738","host":"s3://npm-registry-packages"}},"3.0.0":{"name":"@antora/user-require-helper","version":"3.0.0","description":"A helper function to resolve a module name or path in relation to the specified context and require it.","license":"MPL-2.0","author":{"name":"OpenDevise Inc.","url":"https://opendevise.com"},"contributors":[{"name":"Dan Allen","email":"dan@opendevise.com"}],"repository":{"type":"git","url":"git+https://gitlab.com/antora/user-require-helper.git"},"bugs":{"url":"https://gitlab.com/antora/user-require-helper/issues"},"main":"lib/index.js","exports":{".":"./lib/index.js","./package.json":"./package.json"},"scripts":{"build":"npm test","postbuild":"npm run lint","coverage":"npx -y c8 npm test","coverage-ci":"npx -y nyc node -r ./test/coverage-config.js --test-reporter dot --test-reporter-destination stdout --test-reporter junit --test-reporter-destination reports/tests-xunit.xml --test test/*-test.js","format":"npx -y @biomejs/biome format --write","postformat":"node --disable-warning ExperimentalWarning npm/fix-formatting.js","lint":"npx -y @biomejs/biome lint","postpublish":"npx -y downdoc --postpublish","prepublishOnly":"npx -y downdoc --prepublish","test":"node --test test/*-test.js","pretidy":"npm run lint","tidy":"npm run format","version":"node npm/version.js"},"dependencies":{"@antora/expand-path-helper":"~3.0"},"engines":{"node":">=16.0.0"},"keywords":["require","resolve","user","module","path","absolute","relative","cwd","pwd","home"],"c8":{"all":true,"include":["lib/**/*.js"],"exclude":[],"reporter":["lcov","text"],"reportDir":"reports"},"nyc":{"cache":true,"cacheDir":"node_modules/.cache/nyc","include":["lib/**/*.js"],"exclude":[],"reporter":["cobertura","lcov","text"],"reportDir":"reports"},"_id":"@antora/user-require-helper@3.0.0","gitHead":"7097839674c20307bd8d0902a13803d98687a97f","homepage":"https://gitlab.com/antora/user-require-helper#readme","_nodeVersion":"22.11.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-KIXb8WYhnrnwH7Jj21l1w+et9k5GvcgcqvLOwxqWLEd0uVZOiMFdqFjqbVm3M+zcrs1JXWMeh2LLvxBbQs3q/Q==","shasum":"79a9a506cf4643a6f24b2ee408d86daa7916676c","tarball":"https://registry.npmjs.org/@antora/user-require-helper/-/user-require-helper-3.0.0.tgz","fileCount":4,"unpackedSize":29641,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIC9DoQ/04KrkKlh8+4b62PWFKqBNTfKpqemmkOWZSlWhAiEA/5SMCyinhM7eROMsxjVo2w9CLIsaIa4bw7pNuaSzlrQ="}]},"_npmUser":{"name":"mojavelinux","email":"dan.j.allen@gmail.com"},"directories":{},"maintainers":[{"name":"mojavelinux","email":"dan.j.allen@gmail.com"},{"name":"graphitefriction","email":"sarah@opendevise.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/user-require-helper_3.0.0_1732834465954_0.006374021134738728"},"_hasShrinkwrap":false}},"time":{"created":"2021-07-12T10:27:25.221Z","modified":"2024-11-28T22:54:26.370Z","1.0.0":"2021-07-12T10:27:25.568Z","2.0.0":"2021-07-17T08:18:32.476Z","3.0.0":"2024-11-28T22:54:26.128Z"},"bugs":{"url":"https://gitlab.com/antora/user-require-helper/issues"},"author":{"name":"OpenDevise Inc.","url":"https://opendevise.com"},"license":"MPL-2.0","homepage":"https://gitlab.com/antora/user-require-helper#readme","keywords":["require","resolve","user","module","path","absolute","relative","cwd","pwd","home"],"repository":{"type":"git","url":"git+https://gitlab.com/antora/user-require-helper.git"},"description":"A helper function to resolve a module name or path in relation to the specified context and require it.","contributors":[{"name":"Dan Allen","email":"dan@opendevise.com"}],"maintainers":[{"name":"mojavelinux","email":"dan.j.allen@gmail.com"},{"name":"graphitefriction","email":"sarah@opendevise.com"}],"readme":"# @antora/user-require-helper\n\nA Node.js module that provides helper functions to resolve the module name or path in relation to the specified context and require it (using `userRequire`) or return it (using `userRequire.resolve`).\nThe expanded path is system dependent.\nDeveloped for use in Antora.\n\nThe purpose of this function is to require a JavaScript module (specified as a module name or path request) from the user’s environment.\nThe `require` function in Node.js resolves module names and paths in the environment of the calling script (i.e., the application code).\nThat means it will not find modules in the local _node_modules_ folder (unless the calling script is also located inside that folder) or local relative paths.\nThis assumption is not well suited for user-supplied code.\n\nThe described behavior can be altered using `require.resolve`, which is precisely the functionality this helper encapsulates.\nBuilding on the behavior of `require.resolve`, this function honor prefixes recognized by the **@antora/expand-path-helper** module to anchor the location of the requested module name or path to the resolved context specified in the request.\nSee **Usage** for examples.\n\nFor example, the `.:` or `./` prefix will look for a module name or path, respectively, relative to the specified dot argument.\nIf a context is not specified, and the request argument is a module name, this function will use the function specified by the resolve argument (which defaults to the built-in `require.resolve` function) along with the paths argument, if specified.\nIn other words, if a bare module name is given, the helper resolves the module relative to the specified paths, if specified, otherwise to the environment of the calling script (thus ignoring the base and dot arguments).\n\nThe function inspects the request argument to differentiate between a module name and a path.\nIf the request argument has a file extension, it’s resolved as a path.\nAdditionally, if the request argument begins with a dot (`./`) or dot dot (`../`) segment, and it does not contain a colon (`:`), it’s resolved as a path, _even if it doesn’t have a file extension_.\nOtherwise, it’s resolved as a module name.\n\n**💡 TIP**\\\nIf the request is for a module name that contains a file extension (e.g., `highlight.js`), append `/` to force it to be treated as a module name (e.g., `highlight.js/`).\n\n## Install\n\n```console\n$ npm i @antora/user-require-helper\n```\n\n## API\n\n```js\nfunction userRequire (id[, context])\n```\n\nResolves the module name or path using `userRequire.resolve` and requires it.\nIf the resolved module name or path cannot be found on the local filesystem, an Error with a `MODULE_NOT_FOUND` code is thrown.\n\n* `request` &lt;string> - The module name or path to resolve.\nThis parameter is required and must not be empty.\n* `context` &lt;Object> - Named parameters that control how the request is resolved.\nAll named parameters are optional.\n**Default:** `{}`.\n  * `base` &lt;string> - The base directory from which to resolve a relative module name or path.\n  Passed on to `expandPath`, which assigns the default value `~+`.\n  **Default:** `~+`.\n  * `cwd` &lt;string> - The absolute directory to use as the working directory instead of the current working directory.\n  Passed on to `expandPath`, which assigns the current working directory as the default value.\n  **Default:** `process.cwd()`.\n  * `dot` &lt;string> - The directory to use in place of a leading dot (`.`) segment in the module name or path.\n  Passed on to `expandPath`, which assigns the default value `.`.\n  **Default:** `.`.\n  * `paths` &lt;string[]> - The paths to pass to `require.resolve` when a bare module name is specified.\n  If this argument is empty, no paths are passed to `require.resolve` (which means it uses the built-in paths).\n  **Default:** `[]`.\n  * `context.resolve` &lt;Function> - The resolve function to use to resolve a module name or path request.\n  Defaults to the built-in `require.resolve` function.\n  **Default:** `require.resolve`.\n\n```js\nfunction userRequire.resolve (request[, context])\n```\n\nResolves the module name or path in relation to the specified context and returns it.\nIf the resolved module name or path cannot be found on the local filesystem, an Error with the code `MODULE_NOT_FOUND` is thrown.\n\nSee `userRequire` for description of parameters.\n\n## Usage\n\n### userRequire.resolve\n\nThe `userRequire.resolve` function returns a system-dependent path.\nHere we show the results when used on a Unix-like operating system.\n\n```js\nconst userRequire = require('@antora/user-require-helper')\n\n// request is a path\n\nuserRequire.resolve('/foo/bar.js')\n//=> /foo/bar.js\n\nuserRequire.resolve('~/foo/bar.js')\n//=> $HOME/foo/bar.js\n\nuserRequire.resolve('foo/bar.js')\n//=> $PWD/foo/bar.js\n\nuserRequire.resolve('foo/bar.js', { base: '/base/dir' })\n//=> /base/dir/foo/bar.js\n\nuserRequire.resolve('./foo/bar.js')\n//=> $PWD/foo/bar.js\n\nuserRequire.resolve('./foo/bar.js', { dot: '/dot/dir' })\n//=> /dot/dir/foo/bar.js\n\nuserRequire.resolve('~+/foo/bar.js')\n//=> $PWD/foo/bar.js\n\n// request is a module name\n\nuserRequire.resolve('/path/to/node_modules/foo-bar')\n//=> /path/to/node_modules/foo-bar/main.js\n\nuserRequire.resolve('foo-bar')\n//=> /calling/script/dir/node_modules/foo-bar/main.js\n\nuserRequire.resolve('foo-bar', { paths: ['/other/dir'] })\n//=> /other/dir/node_modules/foo-bar/main.js\n\nuserRequire.resolve('^:foo-bar')\n//=> /calling/script/dir/node_modules/foo-bar/main.js\n\nuserRequire.resolve('^:foo-bar', { paths: ['/other/dir'] })\n//=> /calling/script/dir/node_modules/foo-bar/main.js\n\nuserRequire.resolve(':foo-bar')\n//=> $PWD/node_modules/foo-bar/main.js\n\nuserRequire.resolve(':foo-bar', { base: '/base/dir' })\n//=> /base/dir/node_modules/foo-bar/main.js\n\nuserRequire.resolve('.:foo-bar')\n//=> $PWD/node_modules/foo-bar/main.js\n\nuserRequire.resolve('.:foo-bar', { dot: '/dot/dir' })\n//=> /dot/dir/node_modules/foo-bar/main.js\n\nuserRequire.resolve('./subdir:foo-bar', { dot: '/dot/dir' })\n//=> /dot/dir/subdir/node_modules/foo-bar/main.js\n\nuserRequire.resolve('~+:foo-bar')\n//=> $PWD/node_modules/foo-bar/main.js\n\nuserRequire.resolve('foo-bar.js/')\n//=> /calling/script/dir/node_modules/foo-bar.js/main.js\n```\n\n### userRequire\n\nUses `userRequire.resolve` to resolve the path and returns the object exported by that path by requiring it.\n\n```js\nconst userRequire = require('@antora/user-require-helper')\n\nconst exportedObject = userRequire('./foo/bar.js', { dot: '/dot/dir' })\n```\n\n## Copyright and License\n\nCopyright (C) 2021-present by OpenDevise Inc. and the individual contributors to Antora.\n\nUse of this software is granted under the terms of the [Mozilla Public License Version 2.0](https://www.mozilla.org/en-US/MPL/2.0/) (MPL-2.0).\n","readmeFilename":"README.md"}