load-request-from-cwd-or-npm
Advanced tools
Comparing version 2.0.0 to 2.0.1
14
index.js
@@ -1,5 +0,1 @@ | ||
/*! | ||
* load-request-from-cwd-or-npm | MIT (c) Shinnosuke Watanabe | ||
* https://github.com/shinnn/load-request-from-cwd-or-npm | ||
*/ | ||
'use strict'; | ||
@@ -9,12 +5,6 @@ | ||
const loadRequest = loadFromCwdOrNpm('request').catch(err => { | ||
if (err && err.code === 'MODULE_NOT_FOUND') { | ||
err.message += ' Install "request" and try again. (npm install request)'; | ||
} | ||
const promise = loadFromCwdOrNpm('request'); | ||
return Promise.reject(err); | ||
}); | ||
module.exports = function loadRequestFromCwdOrNpm() { | ||
return loadRequest; | ||
return promise; | ||
}; |
{ | ||
"name": "load-request-from-cwd-or-npm", | ||
"version": "2.0.0", | ||
"description": "Load `request` module from either CWD or npm CLI directory", | ||
"repository": "shinnn/load-request-from-cwd-or-npm", | ||
"author": "Shinnosuke Watanabe (https://github.com/shinnn)", | ||
"scripts": { | ||
"pretest": "eslint --fix --config @shinnn/node index.js test", | ||
"test": "node test/test.js && node test/test-broken-npm.js && node test/test-no-npm.js", | ||
"coverage": "istanbul cover --dir=coverage/test test/test.js && istanbul cover --dir=coverage/test-broken-npm test/test-broken-npm.js && istanbul cover --dir=coverage/test-no-npm test/test-no-npm.js && istanbul report" | ||
}, | ||
"license": "MIT", | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"load", | ||
"resolve", | ||
"require", | ||
"fallback", | ||
"failsafe", | ||
"cwd", | ||
"npm", | ||
"module", | ||
"compare", | ||
"comparison", | ||
"find", | ||
"request", | ||
"http", | ||
"https", | ||
"get", | ||
"put", | ||
"patch", | ||
"post", | ||
"head", | ||
"delete", | ||
"promise", | ||
"promises", | ||
"then" | ||
], | ||
"dependencies": { | ||
"load-from-cwd-or-npm": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"@shinnn/eslint-config-node": "^2.0.0", | ||
"eslint": "^2.13.1", | ||
"istanbul": "^0.4.4", | ||
"tape": "^4.6.0" | ||
} | ||
"name": "load-request-from-cwd-or-npm", | ||
"version": "2.0.1", | ||
"description": "Load `request` module from either CWD or npm CLI directory", | ||
"repository": "shinnn/load-request-from-cwd-or-npm", | ||
"author": "Shinnosuke Watanabe (https://github.com/shinnn)", | ||
"scripts": { | ||
"pretest": "eslint --fix --format=codeframe index.js test/test.js", | ||
"test": "nyc node test/test.js" | ||
}, | ||
"license": "ISC", | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"load", | ||
"resolve", | ||
"require", | ||
"fallback", | ||
"failsafe", | ||
"cwd", | ||
"npm", | ||
"module", | ||
"compare", | ||
"comparison", | ||
"find", | ||
"request", | ||
"http", | ||
"https", | ||
"get", | ||
"put", | ||
"patch", | ||
"post", | ||
"head", | ||
"delete", | ||
"promise", | ||
"promises", | ||
"then" | ||
], | ||
"dependencies": { | ||
"load-from-cwd-or-npm": "^2.2.1" | ||
}, | ||
"devDependencies": { | ||
"@shinnn/eslint-config-node": "^5.0.0", | ||
"clear-module": "^2.1.0", | ||
"eslint": "^4.12.1", | ||
"nyc": "^11.4.0", | ||
"tape": "^4.8.0" | ||
}, | ||
"eslintConfig": { | ||
"extends": "@shinnn/node" | ||
} | ||
} |
# load-request-from-cwd-or-npm | ||
[![NPM version](https://img.shields.io/npm/v/load-request-from-cwd-or-npm.svg)](https://www.npmjs.com/package/load-request-from-cwd-or-npm) | ||
[![npm version](https://img.shields.io/npm/v/load-request-from-cwd-or-npm.svg)](https://www.npmjs.com/package/load-request-from-cwd-or-npm) | ||
[![Build Status](https://travis-ci.org/shinnn/load-request-from-cwd-or-npm.svg?branch=master)](https://travis-ci.org/shinnn/load-request-from-cwd-or-npm) | ||
[![Build status](https://ci.appveyor.com/api/projects/status/6iihj63cx8t3pkf6/branch/master?svg=true)](https://ci.appveyor.com/project/ShinnosukeWatanabe/load-request-from-cwd-or-npm/branch/master) | ||
[![Coverage Status](https://img.shields.io/coveralls/shinnn/load-request-from-cwd-or-npm.svg)](https://coveralls.io/github/shinnn/load-request-from-cwd-or-npm) | ||
[![Dependency Status](https://david-dm.org/shinnn/load-request-from-cwd-or-npm.svg)](https://david-dm.org/shinnn/load-request-from-cwd-or-npm) | ||
[![devDependency Status](https://david-dm.org/shinnn/load-request-from-cwd-or-npm/dev-status.svg)](https://david-dm.org/shinnn/load-request-from-cwd-or-npm#info=devDependencies) | ||
@@ -16,12 +14,12 @@ Load [`request`](https://www.npmjs.com/package/request) module from either CWD or [npm](https://www.npmjs.com/) CLI directory. | ||
``` | ||
$ npm install request@2.72.0 | ||
```console | ||
$ npm install request@2.83.0 | ||
$ du -sh ./node_modules | ||
> 4.7M ./node_modules | ||
5.6M ./node_modules | ||
``` | ||
``` | ||
```console | ||
$ npm install load-request-from-cwd-or-npm@2.0.0 | ||
$ du -sh ./node_modules | ||
> 352K ./node_modules | ||
> 300K ./node_modules | ||
``` | ||
@@ -35,3 +33,3 @@ | ||
[Use npm.](https://docs.npmjs.com/cli/install) | ||
[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/getting-started/what-is-npm). | ||
@@ -50,3 +48,3 @@ ``` | ||
Return: `Object` (a [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise) instance) | ||
Return: `Promise<Function>` | ||
@@ -56,3 +54,3 @@ It loads [`request`](https://github.com/request/request) module from either of these two directories: | ||
1. [`node_modules`](https://docs.npmjs.com/files/folders#node-modules) in the [current working directory](https://nodejs.org/api/process.html#process_process_cwd) | ||
2. `node_modules` in the directory where [`npm` CLI](https://github.com/npm/npm) [dependencies](https://github.com/npm/npm/blob/d48783c339ca8d47a12685b38f2b1ac540e5bf7f/package.json#L32-L100) are installed. | ||
2. `node_modules` in the directory where [`npm` CLI](https://github.com/npm/npm) [dependencies](https://github.com/npm/npm/blob/v5.6.0/package.json#L36-L131) are installed. | ||
@@ -65,5 +63,6 @@ If `request` ins't installed in CWD, it loads `request` from npm CLI directory. | ||
loadRequestFromCwdOrNpm().then(request => { | ||
request; //=> {[Function: request] get: [Function], head: [Function], ...} | ||
}); | ||
(async () => { | ||
const request = await loadRequestFromCwdOrNpm(); | ||
//=> {[Function: request] get: [Function], head: [Function], ...} | ||
})(); | ||
``` | ||
@@ -77,5 +76,6 @@ | ||
loadRequestFromCwdOrNpm().then(request => { | ||
request; // Loaded from npm CLI directory because the CWD version is older | ||
}); | ||
(async () => { | ||
// Loaded from npm CLI directory because the CWD version is older | ||
const request = await loadRequestFromCwdOrNpm(); | ||
})(); | ||
``` | ||
@@ -87,4 +87,2 @@ | ||
Copyright (c) 2015 - 2016 [Shinnosuke Watanabe](https://github.com/shinnn) | ||
Licensed under [the MIT License](./LICENSE). | ||
[ISC License](./LICENSE) © 2017 Shinnosuke Watanabe |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5157
5
6
82
1
Updatedload-from-cwd-or-npm@^2.2.1