diff options
Diffstat (limited to 'node_modules/import-from')
| -rw-r--r-- | node_modules/import-from/index.js | 12 | ||||
| -rw-r--r-- | node_modules/import-from/license | 21 | ||||
| -rw-r--r-- | node_modules/import-from/package.json | 38 | ||||
| -rw-r--r-- | node_modules/import-from/readme.md | 70 |
4 files changed, 141 insertions, 0 deletions
diff --git a/node_modules/import-from/index.js b/node_modules/import-from/index.js new file mode 100644 index 00000000..884bd525 --- /dev/null +++ b/node_modules/import-from/index.js @@ -0,0 +1,12 @@ +'use strict'; +const resolveFrom = require('resolve-from'); + +module.exports = (fromDir, moduleId) => require(resolveFrom(fromDir, moduleId)); + +module.exports.silent = (fromDir, moduleId) => { + try { + return require(resolveFrom(fromDir, moduleId)); + } catch (err) { + return null; + } +}; diff --git a/node_modules/import-from/license b/node_modules/import-from/license new file mode 100644 index 00000000..654d0bfe --- /dev/null +++ b/node_modules/import-from/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/import-from/package.json b/node_modules/import-from/package.json new file mode 100644 index 00000000..2fdd1e6b --- /dev/null +++ b/node_modules/import-from/package.json @@ -0,0 +1,38 @@ +{ + "name": "import-from", + "version": "2.1.0", + "description": "Import a module like with `require()` but from a given path", + "license": "MIT", + "repository": "sindresorhus/import-from", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "engines": { + "node": ">=4" + }, + "scripts": { + "test": "xo && ava" + }, + "files": [ + "index.js" + ], + "keywords": [ + "require", + "resolve", + "path", + "module", + "from", + "like", + "import", + "path" + ], + "dependencies": { + "resolve-from": "^3.0.0" + }, + "devDependencies": { + "ava": "*", + "xo": "*" + } +} diff --git a/node_modules/import-from/readme.md b/node_modules/import-from/readme.md new file mode 100644 index 00000000..51fd7012 --- /dev/null +++ b/node_modules/import-from/readme.md @@ -0,0 +1,70 @@ +# import-from [](https://travis-ci.org/sindresorhus/import-from) + +> Import a module like with [`require()`](https://nodejs.org/api/globals.html#globals_require) but from a given path + + +## Install + +``` +$ npm install --save import-from +``` + + +## Usage + +```js +const importFrom = require('import-from'); + +// There is a file at `./foo/bar.js` + +importFrom('foo', './bar'); +``` + + +## API + +### importFrom(fromDir, moduleId) + +Like `require()`, throws when the module can't be found. + +### importFrom.silent(fromDir, moduleId) + +Returns `null` instead of throwing when the module can't be found. + +#### fromDir + +Type: `string` + +Directory to import from. + +#### moduleId + +Type: `string` + +What you would use in `require()`. + + +## Tip + +Create a partial using a bound function if you want to import from the same `fromDir` multiple times: + +```js +const importFromFoo = importFrom.bind(null, 'foo'); + +importFromFoo('./bar'); +importFromFoo('./baz'); +``` + + +## Related + +- [import-cwd](https://github.com/sindresorhus/import-cwd) - Import a module from the current working directory +- [resolve-from](https://github.com/sindresorhus/resolve-from) - Resolve the path of a module from a given path +- [resolve-cwd](https://github.com/sindresorhus/resolve-cwd) - Resolve the path of a module from the current working directory +- [resolve-pkg](https://github.com/sindresorhus/resolve-pkg) - Resolve the path of a package regardless of it having an entry point +- [import-lazy](https://github.com/sindresorhus/import-lazy) - Import modules lazily + + +## License + +MIT © [Sindre Sorhus](https://sindresorhus.com) |
