resolve-pkg
Advanced tools
Comparing version 0.1.0 to 0.2.0
15
index.js
@@ -8,4 +8,13 @@ 'use strict'; | ||
var parts = moduleId.split(path.sep); | ||
var pkg = path.join(parts.shift(), 'package.json'); | ||
var parts = moduleId.replace(/\\/g, '/').split('/'); | ||
var packageName = ''; | ||
// handle scoped package name | ||
if (parts.length > 0 && parts[0][0] === '@') { | ||
packageName += parts.shift() + '/'; | ||
} | ||
packageName += parts.shift(); | ||
var pkg = path.join(packageName, 'package.json'); | ||
var resolved = resolveFrom(opts.cwd || '.', pkg); | ||
@@ -17,3 +26,3 @@ | ||
return path.join(path.dirname(resolved), parts.join(path.sep)); | ||
return path.join(path.dirname(resolved), parts.join('/')); | ||
}; |
{ | ||
"name": "resolve-pkg", | ||
"version": "0.1.0", | ||
"description": "Resolve the path of a package regardless of it having an entry", | ||
"version": "0.2.0", | ||
"description": "Resolve the path of a package regardless of it having an entry point", | ||
"license": "MIT", | ||
@@ -43,5 +43,6 @@ "repository": "sindresorhus/resolve-pkg", | ||
"ava": "*", | ||
"grunt-svgmin": "3.1.0", | ||
"xo": "*" | ||
"grunt-svgmin": "3.3.0", | ||
"xo": "*", | ||
"@someprivate/module-test": "file:./fixtures/private-module-test" | ||
} | ||
} |
# resolve-pkg [![Build Status](https://travis-ci.org/sindresorhus/resolve-pkg.svg?branch=master)](https://travis-ci.org/sindresorhus/resolve-pkg) | ||
> Resolve the path of a package regardless of it having an entry | ||
> Resolve the path of a package regardless of it having an entry point | ||
@@ -45,3 +45,3 @@ Some packages like CLI tools and grunt tasks don't have a entry point, like `"main": "foo.js"` in package.json, resulting in them not being resolvable by `require.resolve()`. Unlike `require.resolve()`, this module also resolves packages without an entry point, returns `null` instead of throwing when the module can't be found, and resolves from `process.cwd()` instead `__dirname` by default. | ||
Type: `boolean` | ||
Type: `boolean`<br> | ||
Default: `process.cwd()` | ||
@@ -63,2 +63,2 @@ | ||
MIT © [Sindre Sorhus](http://sindresorhus.com) | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) |
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
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
4442
19
4