load-plugin
Advanced tools
Comparing version 2.2.1 to 2.2.2
70
index.js
@@ -1,18 +0,18 @@ | ||
'use strict'; | ||
'use strict' | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var resolve = require('resolve-from'); | ||
var npmPrefix = require('npm-prefix')(); | ||
var fs = require('fs') | ||
var path = require('path') | ||
var resolve = require('resolve-from').silent | ||
var npmPrefix = require('npm-prefix')() | ||
module.exports = loadPlugin; | ||
loadPlugin.resolve = resolvePlugin; | ||
module.exports = loadPlugin | ||
loadPlugin.resolve = resolvePlugin | ||
var electron = process.versions.electron !== undefined; | ||
var argv = process.argv[1] || /* istanbul ignore next */ ''; | ||
var nvm = process.env.NVM_BIN; | ||
var globally = electron || argv.indexOf(npmPrefix) === 0; | ||
var windows = process.platform === 'win32'; | ||
var prefix = windows ? /* istanbul ignore next */ '' : 'lib'; | ||
var globals = path.resolve(npmPrefix, prefix, 'node_modules'); | ||
var electron = process.versions.electron !== undefined | ||
var argv = process.argv[1] || /* istanbul ignore next */ '' | ||
var nvm = process.env.NVM_BIN | ||
var globally = electron || argv.indexOf(npmPrefix) === 0 | ||
var windows = process.platform === 'win32' | ||
var prefix = windows ? /* istanbul ignore next */ '' : 'lib' | ||
var globals = path.resolve(npmPrefix, prefix, 'node_modules') | ||
@@ -27,3 +27,3 @@ /* istanbul ignore next - If we’re in Electron, we’re running in a modified | ||
if (electron && nvm && !fs.existsSync(globals)) { | ||
globals = path.resolve(nvm, '..', prefix, 'node_modules'); | ||
globals = path.resolve(nvm, '..', prefix, 'node_modules') | ||
} | ||
@@ -33,3 +33,3 @@ | ||
function loadPlugin(name, options) { | ||
return require(resolvePlugin(name, options) || name); | ||
return require(resolvePlugin(name, options) || name) | ||
} | ||
@@ -50,15 +50,15 @@ | ||
function resolvePlugin(name, options) { | ||
var settings = options || {}; | ||
var prefix = settings.prefix; | ||
var cwd = settings.cwd; | ||
var filePath; | ||
var sources; | ||
var length; | ||
var index; | ||
var plugin; | ||
var settings = options || {} | ||
var prefix = settings.prefix | ||
var cwd = settings.cwd | ||
var filePath | ||
var sources | ||
var length | ||
var index | ||
var plugin | ||
if (cwd && typeof cwd === 'object') { | ||
sources = cwd.concat(); | ||
sources = cwd.concat() | ||
} else { | ||
sources = [cwd || process.cwd()]; | ||
sources = [cwd || process.cwd()] | ||
} | ||
@@ -69,3 +69,3 @@ | ||
if (settings.global == null ? globally : settings.global) { | ||
sources.push(globals); | ||
sources.push(globals) | ||
} | ||
@@ -75,6 +75,6 @@ | ||
if (prefix) { | ||
prefix = prefix.charAt(prefix.length - 1) === '-' ? prefix : prefix + '-'; | ||
prefix = prefix.charAt(prefix.length - 1) === '-' ? prefix : prefix + '-' | ||
if (name.slice(0, prefix.length) !== prefix) { | ||
plugin = prefix + name; | ||
plugin = prefix + name | ||
} | ||
@@ -84,15 +84,15 @@ } | ||
length = sources.length; | ||
index = -1; | ||
length = sources.length | ||
index = -1 | ||
while (++index < length) { | ||
cwd = sources[index]; | ||
filePath = (plugin && resolve(cwd, plugin)) || resolve(cwd, name); | ||
cwd = sources[index] | ||
filePath = (plugin && resolve(cwd, plugin)) || resolve(cwd, name) | ||
if (filePath) { | ||
return filePath; | ||
return filePath | ||
} | ||
} | ||
return null; | ||
return null | ||
} |
{ | ||
"name": "load-plugin", | ||
"version": "2.2.1", | ||
"version": "2.2.2", | ||
"description": "Load a submodule, plugin, or file", | ||
@@ -12,3 +12,3 @@ "license": "MIT", | ||
], | ||
"repository": "https://github.com/wooorm/load-plugin.git", | ||
"repository": "wooorm/load-plugin", | ||
"bugs": "https://github.com/wooorm/load-plugin/issues", | ||
@@ -27,25 +27,34 @@ "author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)", | ||
"npm-prefix": "^1.2.0", | ||
"resolve-from": "^2.0.0" | ||
"resolve-from": "^4.0.0" | ||
}, | ||
"devDependencies": { | ||
"nyc": "^11.0.0", | ||
"remark-cli": "^3.0.0", | ||
"prettier": "^1.12.0", | ||
"remark-cli": "^5.0.0", | ||
"remark-lint": "^6.0.0", | ||
"remark-preset-wooorm": "^3.0.0", | ||
"remark-preset-wooorm": "^4.0.0", | ||
"tape": "^4.0.0", | ||
"xo": "^0.18.0" | ||
"xo": "^0.20.0" | ||
}, | ||
"scripts": { | ||
"build-md": "remark . -qfo", | ||
"build": "npm run build-md", | ||
"lint": "xo", | ||
"format": "remark . -qfo && prettier --write '**/*.js' && xo --fix", | ||
"test-api": "node test", | ||
"test-coverage": "nyc --reporter lcov tape test/index.js", | ||
"test": "npm run build && npm run lint && npm run test-coverage" | ||
"test": "npm run format && npm run test-coverage" | ||
}, | ||
"prettier": { | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"singleQuote": true, | ||
"bracketSpacing": false, | ||
"semi": false, | ||
"trailingComma": "none" | ||
}, | ||
"xo": { | ||
"space": true, | ||
"prettier": true, | ||
"esnext": false, | ||
"rules": { | ||
"import/no-dynamic-require": "off", | ||
"no-var": "off", | ||
"prefer-arrow-callback": "off", | ||
"no-eq-null": "off", | ||
@@ -62,4 +71,6 @@ "eqeqeq": "off" | ||
"remarkConfig": { | ||
"plugins": ["preset-wooorm"] | ||
"plugins": [ | ||
"preset-wooorm" | ||
] | ||
} | ||
} |
@@ -24,12 +24,12 @@ # load-plugin [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov] | ||
```javascript | ||
var load = require('load-plugin'); | ||
var load = require('load-plugin') | ||
load.resolve('lint', {prefix: 'remark'}); | ||
//=> '/Users/tilde/projects/oss/load-plugin/node_modules/remark-lint/index.js' | ||
load.resolve('lint', {prefix: 'remark'}) | ||
// => '/Users/tilde/projects/oss/load-plugin/node_modules/remark-lint/index.js' | ||
load.resolve('./index.js', {prefix: 'remark'}); | ||
//=> '/Users/tilde/projects/oss/load-plugin/index.js' | ||
load.resolve('./index.js', {prefix: 'remark'}) | ||
// => '/Users/tilde/projects/oss/load-plugin/index.js' | ||
load.require('lint', {prefix: 'remark'}); | ||
//=> [Function: lint] | ||
load.require('lint', {prefix: 'remark'}) | ||
// => [Function: lint] | ||
``` | ||
@@ -36,0 +36,0 @@ |
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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
8753
5
87
7
+ Addedresolve-from@4.0.0(transitive)
- Removedresolve-from@2.0.0(transitive)
Updatedresolve-from@^4.0.0