this
Traverses up the directory tree and returns the first module found
Last updated a year ago by lukechilds .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install this 
SYNC missed versions from official npm registry.

this

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 this

Or if using for tests you'll probably want:

npm install --save-dev this

Usage

Just require this 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 'this';

// and then in sub folders it's still just:
import myPackage from 'this';

e.g without import transpilation:

const test = require('tape');
const myPackage = require('this');

License

MIT © Luke Childs

Current Tags

  • 1.1.0                                ...           latest (a year ago)

9 Versions

  • 1.1.0                                ...           a year ago
  • 1.0.2                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
  • 0.1.7                                ...           8 years ago
  • 0.1.6                                ...           8 years ago
  • 0.1.5                                ...           8 years ago
  • 0.1.4                                ...           8 years ago
  • 0.1.1                                ...           8 years ago
  • 0.1.0                                ...           8 years ago
Maintainers (1)
Downloads
Today 0
This Week 3
This Month 17
Last Day 1
Last Week 10
Last Month 5
Dependencies (1)
Dev Dependencies (5)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |