You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
Luke Childs 3b46c32e87 1.0.0 7 years ago
src Use `pkg-dir` 7 years ago
test root-module => get-root-module 7 years ago
.gitignore Initial commit 7 years ago
.travis.yml Initial commit 7 years ago
LICENSE Initial commit 7 years ago
README.md Add usage section to readme 7 years ago
package.json 1.0.0 7 years ago

README.md

get-root-module

Traverses up the directory tree and returns the first module found

Build Status Coverage Status npm

Useful in tests so you don't have to require the package you're testing via relative paths.

Starts directory traversal from process.cwd() so this should really only be used in tests or CLI apps.

Install

npm install --save get-root-module

Or if using for tests you'll probably want:

npm install --save-dev get-root-module

Usage

Just require get-root-module the same way you would require the root module with a relative path.

e.g instead of:

import test from 'ava';
import myPackage from '../';

// and then in sub folders
import myPackage from '../../';

You can now do:

import test from 'ava';
import myPackage from 'get-root-module';

// and then in sub folders it's still just:
import myPackage from 'get-root-module';

License

MIT © Luke Childs