fd-package-json
Utilities for finding the closest package.json file
Last updated 10 months ago by 43081j .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install fd-package-json 
SYNC missed versions from official npm registry.

fd-package-json

Finds the closest package.json and returns the path or the contents.

Install

npm i -S fd-package-json

Usage

To retrieve the path of the closest package, you can use findPackagePath:

import {findPackagePath} from 'fd-package-json';

// Closest package path to cwd of the process
await findPackagePath(process.cwd());

// Closest package path to the current file (CJS)
await findPackagePath(__dirname);

// Closest package path to the current file (ESM)
await findPackagePath(fileURLToPath(new URL('.', import.meta.url)));

To retrieve the package itself, you may use findPackage with the same parameter:

await findPackage(process.cwd()); // Returns the JSON of the package if found

Synchronous methods also exist:

findPackageSync(process.cwd()); // returns the package

findPackagePathSync(process.cwd()); // returns the package path

License

MIT

Current Tags

  • 2.0.0                                ...           latest (10 months ago)
  • 2.0.0-beta.0                                ...           next (2 years ago)

6 Versions

  • 2.0.0                                ...           10 months ago
  • 2.0.0-beta.0                                ...           2 years ago
  • 1.2.0                                ...           2 years ago
  • 1.1.0                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
  • 0.0.1                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 2
Dependencies (1)
Dev Dependencies (9)

Copyright 2013 - present © cnpmjs.org | Home |