Socket
Socket
Sign inDemoInstall

pkg-dir

Package Overview
Dependencies
1
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

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)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc