Socket
Socket
Sign inDemoInstall

dont-look-up

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    dont-look-up

Stop requirejs from traversing at a certain point


Version published
Maintainers
1
Install size
6.35 kB
Created

Readme

Source

don't look up

NPM

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.

describe('my-tests', () => {
    require('dont-look-up')(__dirname);

    it('should not traverse beyond this directory', () => { ... });
});

Example

Consider the following tree

└── repository
    ├── package
    │   ├── index.js
    │   ├── package.json
    │   └── node_modules
    │       └── child-level-module
    └── node_modules
        └── parent-level-module
package/index.js
require('parent-level-module'); // works
require('child-level-module'); // works

With "don't look up"

require('dont-look-up')(__dirname);
require('parent-level-module'); // throws error
require('child-level-module'); // works

FAQs

Last updated on 14 Mar 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc