Browse Source

Rename to requirable

pull/2/head
Luke Childs 7 years ago
parent
commit
7b7a6851a0
  1. 14
      README.md
  2. 10
      package.json
  3. 4
      test/requireable.js

14
README.md

@ -1,10 +1,10 @@
# requireable # requirable
> Enables a module to require itself by name > Enables a module to require itself by name
[![Build Status](https://travis-ci.org/lukechilds/requireable.svg?branch=master)](https://travis-ci.org/lukechilds/requireable) [![Build Status](https://travis-ci.org/lukechilds/requirable.svg?branch=master)](https://travis-ci.org/lukechilds/requirable)
[![Coverage Status](https://coveralls.io/repos/github/lukechilds/requireable/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/requireable?branch=master) [![Coverage Status](https://coveralls.io/repos/github/lukechilds/requirable/badge.svg?branch=master)](https://coveralls.io/github/lukechilds/requirable?branch=master)
[![npm](https://img.shields.io/npm/v/requireable.svg)](https://www.npmjs.com/package/requireable) [![npm](https://img.shields.io/npm/v/requirable.svg)](https://www.npmjs.com/package/requirable)
Mocks the require command to include the current package when the `name` from the current `package.json` is required. Mocks the require command to include the current package when the `name` from the current `package.json` is required.
@ -13,7 +13,7 @@ Uses `process.cwd()` to find the current `package.json` so this is only meant to
## Install ## Install
```shell ```shell
npm install --save-dev requireable npm install --save-dev requirable
``` ```
## Usage ## Usage
@ -32,7 +32,7 @@ Some tests runners such as [AVA](https://github.com/avajs/ava) can require packa
```json ```json
"ava": { "ava": {
"require": [ "require": [
"requireable" "requirable"
] ]
}, },
``` ```
@ -55,7 +55,7 @@ Some tests runners such as [AVA](https://github.com/avajs/ava) can require packa
## API ## API
### require('requireable') ### require('requirable')
Patches the require function to be able to require the current module by name. Patches the require function to be able to require the current module by name.

10
package.json

@ -1,5 +1,5 @@
{ {
"name": "requireable", "name": "requirable",
"version": "1.0.3", "version": "1.0.3",
"description": "Enables a module to require itself by name", "description": "Enables a module to require itself by name",
"main": "src/index.js", "main": "src/index.js",
@ -12,12 +12,12 @@
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/lukechilds/requireable.git" "url": "git+https://github.com/lukechilds/requirable.git"
}, },
"keywords": [ "keywords": [
"find", "find",
"require", "require",
"requireable", "requirable",
"self", "self",
"root", "root",
"current", "current",
@ -26,9 +26,9 @@
"author": "Luke Childs <lukechilds123@gmail.com> (http://lukechilds.co.uk)", "author": "Luke Childs <lukechilds123@gmail.com> (http://lukechilds.co.uk)",
"license": "MIT", "license": "MIT",
"bugs": { "bugs": {
"url": "https://github.com/lukechilds/requireable/issues" "url": "https://github.com/lukechilds/requirable/issues"
}, },
"homepage": "https://github.com/lukechilds/requireable", "homepage": "https://github.com/lukechilds/requirable",
"dependencies": { "dependencies": {
"mock-require": "^2.0.2", "mock-require": "^2.0.2",
"pkg-dir": "^2.0.0" "pkg-dir": "^2.0.0"

4
test/requireable.js

@ -3,10 +3,10 @@ import test from 'ava';
test.serial(`outputs success info`, t => { test.serial(`outputs success info`, t => {
const output = require('../'); const output = require('../');
t.true(output.success); t.true(output.success);
t.is(output.name, 'requireable'); t.is(output.name, 'requirable');
}); });
test.serial(`requiring package name requires root package`, t => { test.serial(`requiring package name requires root package`, t => {
// eslint-disable-next-line import/no-extraneous-dependencies, import/no-unresolved // eslint-disable-next-line import/no-extraneous-dependencies, import/no-unresolved
t.notThrows(() => require('requireable')); t.notThrows(() => require('requirable'));
}); });

Loading…
Cancel
Save