https://github.com/fiverr/dont_look_up_package
🙈 Stop requirejs from traversing at a certain point
https://github.com/fiverr/dont_look_up_package
modules mono-repo monorepo requirejs testing
Last synced: about 1 year ago
JSON representation
🙈 Stop requirejs from traversing at a certain point
- Host: GitHub
- URL: https://github.com/fiverr/dont_look_up_package
- Owner: fiverr
- License: mit
- Created: 2018-03-14T16:20:42.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-03-21T22:56:46.000Z (over 3 years ago)
- Last Synced: 2025-04-04T18:11:47.856Z (about 1 year ago)
- Topics: modules, mono-repo, monorepo, requirejs, testing
- Language: JavaScript
- Homepage: https://fiverr.github.io/dont_look_up_package/
- Size: 12.7 KB
- Stars: 2
- Watchers: 61
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# don't look up [](https://circleci.com/gh/fiverr/dont_look_up_package)
[](https://www.npmjs.com/package/dont-look-up)
## Stop requirejs from traversing at a certain point
> Whatever you do — don't look up
Stop requirejs' search path from looking higher than a given directory. This behaviour is should prevent your application from finding modules installed globally, or on a higher level directory, like in a mono-repo containing many packages.
```js
describe('my-tests', () => {
require('dont-look-up')(__dirname);
it('Should only traverse up to current root directory', () => { ... });
});
```
### Example
Consider the following tree
```
└── repository
  ├── package
  │  ├── index.js
  │  ├── package.json
  │  └── node_modules
  │  └── child-level-module
  ├── index.js
  ├── package.json
  └── node_modules
  └── parent-level-module
```
| package/index.js
| ---
```js
require('parent-level-module'); // works
require('child-level-module'); // works
```
With "don't look up"
```js
require('dont-look-up')(__dirname);
require('parent-level-module'); // throws error
require('child-level-module'); // works
```