Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zkochan/deep-require-from
Require a module like `require()` but via a sequence of nested packages
https://github.com/zkochan/deep-require-from
Last synced: 10 days ago
JSON representation
Require a module like `require()` but via a sequence of nested packages
- Host: GitHub
- URL: https://github.com/zkochan/deep-require-from
- Owner: zkochan
- License: mit
- Created: 2017-05-08T19:35:49.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-08-06T20:11:42.000Z (over 7 years ago)
- Last Synced: 2024-10-26T16:53:54.844Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 20.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# deep-require-from
> Require a module like \`require()\` but via a sequence of nested packages
[![npm version](https://img.shields.io/npm/v/deep-require-from.svg)](https://www.npmjs.com/package/deep-require-from) [![Build Status](https://img.shields.io/travis/zkochan/deep-require-from/master.svg)](https://travis-ci.org/zkochan/deep-require-from)
## Installation
```sh
npm i -S deep-require-from
```## Usage
```js
'use strict'
const deepRequireFrom = require('deep-require-from')const pkg = deepRequireFrom(__dirname, ['mos', 'chalk', './package.json'])
console.log(pkg.name)
//> chalk
```## API
### `deepRequireFrom(fromDir, moduleIds)`
Like `require()`, throws when the module can't be found.
### `deepRequireFrom.silent(fromDir, moduleIds)`
Returns `null` instead of throwing when the module can't be found.
#### moduleIds
Type: `string[]`
An array of module IDs, a module ID is something that you pass to `require()`.
## Related
- [deep-resolve-from](https://github.com/zkochan/deep-resolve-from) - Resolve the path of a module through a sequence of packages
- [deep-resolve-cwd](https://github.com/zkochan/deep-resolve-cwd) - Resolve the path of a module through a sequence of packages from the current working directory
- [req-from](https://github.com/sindresorhus/req-from) - Require a module like `require()` but from a given path## License
[MIT](./LICENSE) © [Zoltan Kochan](https://www.kochan.io)