Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lukechilds/this
Traverses up the directory tree and returns the first module found
https://github.com/lukechilds/this
module package require test test-utilities test-utils testing testing-tools
Last synced: 5 days ago
JSON representation
Traverses up the directory tree and returns the first module found
- Host: GitHub
- URL: https://github.com/lukechilds/this
- Owner: lukechilds
- License: mit
- Created: 2017-07-19T08:36:10.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-10-10T23:38:57.000Z (about 5 years ago)
- Last Synced: 2024-10-26T12:37:19.199Z (18 days ago)
- Topics: module, package, require, test, test-utilities, test-utils, testing, testing-tools
- Language: JavaScript
- Homepage:
- Size: 27.3 KB
- Stars: 7
- Watchers: 4
- Forks: 2
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# this
> Traverses up the directory tree and returns the first module found
[![Build Status](https://travis-ci.org/lukechilds/this.svg?branch=master)](https://travis-ci.org/lukechilds/this)
[![Coverage Status](https://coveralls.io/repos/github/lukechilds/this/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/this?branch=master)
[![npm](https://img.shields.io/npm/v/this.svg)](https://www.npmjs.com/package/this)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
```shell
npm install --save this
```Or if using for tests you'll probably want:
```shell
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:
```js
import test from 'ava';
import myPackage from '../';// and then in sub folders
import myPackage from '../../';
```You can now do:
```js
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:
```js
const test = require('tape');
const myPackage = require('this');
```## License
MIT © Luke Childs