pkg-dir

WebJar for pkg-dir

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

pkg-dir
Last Version

Last Version

4.2.0
Release Date

Release Date

Type

Type

jar
Description

Description

pkg-dir
WebJar for pkg-dir
Project URL

Project URL

https://www.webjars.org
Source Code Management

Source Code Management

https://github.com/sindresorhus/pkg-dir

Download pkg-dir

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/pkg-dir/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>pkg-dir</artifactId>
    <version>4.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/pkg-dir/
implementation 'org.webjars.npm:pkg-dir:4.2.0'
// https://jarcasting.com/artifacts/org.webjars.npm/pkg-dir/
implementation ("org.webjars.npm:pkg-dir:4.2.0")
'org.webjars.npm:pkg-dir:jar:4.2.0'
<dependency org="org.webjars.npm" name="pkg-dir" rev="4.2.0">
  <artifact name="pkg-dir" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='pkg-dir', version='4.2.0')
)
libraryDependencies += "org.webjars.npm" % "pkg-dir" % "4.2.0"
[org.webjars.npm/pkg-dir "4.2.0"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm : find-up jar [4.0.0,5)

Project Modules

There are no modules declared in this project.

pkg-dir

Find the root directory of a Node.js project or npm package

Install

$ npm install pkg-dir

Usage

/
└── Users
    └── sindresorhus
        └── foo
            ├── package.json
            └── bar
                ├── baz
                └── example.js
// example.js
const pkgDir = require('pkg-dir');

(async () => {
	const rootDir = await pkgDir(__dirname);

	console.log(rootDir);
	//=> '/Users/sindresorhus/foo'
})();

API

pkgDir(cwd?)

Returns a Promise for either the project root path or undefined if it couldn't be found.

pkgDir.sync(cwd?)

Returns the project root path or undefined if it couldn't be found.

cwd

Type: string
Default: process.cwd()

Directory to start from.

Related

  • pkg-dir-cli - CLI for this module
  • pkg-up - Find the closest package.json file
  • find-up - Find a file by walking up parent directories

Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.

Versions

Version
4.2.0
3.0.0
2.0.0
1.0.0