require-one-of
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -5,2 +5,12 @@ # Change Log | ||
<a name="1.0.7"></a> | ||
## [1.0.7](https://github.com/Kikobeats/require-one-of/compare/v1.0.6...v1.0.7) (2019-03-29) | ||
### Bug Fixes | ||
* support npx relative packages ([6dc47dd](https://github.com/Kikobeats/require-one-of/commit/6dc47dd)) | ||
<a name="1.0.6"></a> | ||
@@ -7,0 +17,0 @@ ## [1.0.6](https://github.com/Kikobeats/require-one-of/compare/v1.0.5...v1.0.6) (2019-03-08) |
@@ -5,3 +5,3 @@ { | ||
"homepage": "https://documentup.com/Kikobeats/require-one-of", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"main": "src/index.js", | ||
@@ -8,0 +8,0 @@ "author": { |
'use strict' | ||
const humanizeList = require('humanize-list') | ||
const resolveFrom = require('resolve-from') | ||
const humanizeList = require('humanize-list') | ||
const assert = require('assert') | ||
const path = require('path') | ||
@@ -16,5 +17,17 @@ const cache = {} | ||
const relativeNodeModulesPath = path.resolve(__dirname, '..', '..') | ||
/** | ||
* Normally, you are going to get node_modules from the current | ||
* execution path. | ||
* | ||
* This is not applied when you are running it using `npx` | ||
* In that case, node_modules is relative to the dependency itself. | ||
*/ | ||
const resolveModule = module => | ||
resolveFrom.silent(process.cwd(), module) || resolveFrom.silent(relativeNodeModulesPath, module) | ||
const find = (modules, error = createError) => { | ||
for (const module of modules) { | ||
const modulePath = resolveFrom.silent(process.cwd(), module) | ||
const modulePath = resolveModule(module) | ||
if (modulePath) return require(modulePath) | ||
@@ -21,0 +34,0 @@ } |
9511
35