get-root-module

Traverses up the directory tree and returns the first module found

Renamed to this
Last updated 3 years ago by lukechilds .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install get-root-module 
SYNC missed versions from official npm registry.

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';

e.g without import transpilation:

const test = require('tape');
const myPackage = require('get-root-module');

License

MIT © Luke Childs

Current Tags

  • 1.0.1                                ...           latest (3 years ago)

5 Versions

  • 1.0.1 [deprecated]           ...           3 years ago
  • 1.0.0 [deprecated]           ...           3 years ago
  • 0.1.3 [deprecated]           ...           3 years ago
  • 0.1.2 [deprecated]           ...           3 years ago
  • 0.1.1 [deprecated]           ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 1
Dependencies (1)
Dev Dependencies (5)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |