pkg-dir
Advanced tools
Comparing version 1.0.0 to 2.0.0
14
index.js
'use strict'; | ||
var path = require('path'); | ||
var findUp = require('find-up'); | ||
const path = require('path'); | ||
const findUp = require('find-up'); | ||
module.exports = function (cwd) { | ||
return findUp('package.json', {cwd: cwd}).then(function (fp) { | ||
return fp ? path.dirname(fp) : null; | ||
}); | ||
}; | ||
module.exports = cwd => findUp('package.json', {cwd}).then(fp => fp ? path.dirname(fp) : null); | ||
module.exports.sync = function (cwd) { | ||
var fp = findUp.sync('package.json', {cwd: cwd}); | ||
module.exports.sync = cwd => { | ||
const fp = findUp.sync('package.json', {cwd}); | ||
return fp ? path.dirname(fp) : null; | ||
}; |
{ | ||
"name": "pkg-dir", | ||
"version": "1.0.0", | ||
"description": "Find the root directory of a npm package", | ||
"version": "2.0.0", | ||
"description": "Find the root directory of a Node.js project or npm package", | ||
"license": "MIT", | ||
@@ -13,3 +13,3 @@ "repository": "sindresorhus/pkg-dir", | ||
"engines": { | ||
"node": ">=0.10.0" | ||
"node": ">=4" | ||
}, | ||
@@ -37,3 +37,2 @@ "scripts": { | ||
"match", | ||
"package", | ||
"resolve", | ||
@@ -50,3 +49,3 @@ "parent", | ||
"dependencies": { | ||
"find-up": "^1.0.0" | ||
"find-up": "^2.1.0" | ||
}, | ||
@@ -53,0 +52,0 @@ "devDependencies": { |
# pkg-dir [![Build Status](https://travis-ci.org/sindresorhus/pkg-dir.svg?branch=master)](https://travis-ci.org/sindresorhus/pkg-dir) | ||
> Find the root directory of a npm package | ||
> Find the root directory of a Node.js project or npm package | ||
@@ -28,6 +28,6 @@ | ||
// example.js | ||
var pkgDir = require('pkg-dir'); | ||
const pkgDir = require('pkg-dir'); | ||
pkgDir(__dirname).then(function (rootPath) { | ||
console.log(rootPath); | ||
pkgDir(__dirname).then(rootDir => { | ||
console.log(rootDir); | ||
//=> '/Users/sindresorhus/foo' | ||
@@ -42,11 +42,11 @@ }); | ||
Returns a promise that resolves to the package root path or `null`. | ||
Returns a `Promise` for either the project root path or `null` if it couldn't be found. | ||
### pkgDir.sync([cwd]) | ||
Returns the package root path or `null`. | ||
Returns the project root path or `null`. | ||
#### cwd | ||
Type: `string` | ||
Type: `string`<br> | ||
Default: `process.cwd()` | ||
@@ -60,2 +60,3 @@ | ||
- [pkg-dir-cli](https://github.com/sindresorhus/pkg-dir-cli) - CLI for this module | ||
- [pkg-up](https://github.com/sindresorhus/pkg-up) - Find the closest package.json file | ||
- [find-up](https://github.com/sindresorhus/find-up) - Find a file by walking up parent directories | ||
@@ -66,2 +67,2 @@ | ||
MIT © [Sindre Sorhus](http://sindresorhus.com) | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) |
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
3497
65
8
1
+ Addedfind-up@2.1.0(transitive)
+ Addedlocate-path@2.0.0(transitive)
+ Addedp-limit@1.3.0(transitive)
+ Addedp-locate@2.0.0(transitive)
+ Addedp-try@1.0.0(transitive)
+ Addedpath-exists@3.0.0(transitive)
- Removedfind-up@1.1.2(transitive)
- Removedpath-exists@2.1.0(transitive)
- Removedpinkie@2.0.4(transitive)
- Removedpinkie-promise@2.0.1(transitive)
Updatedfind-up@^2.1.0