JSPM

new-find-package-json

2.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 651814
  • Score
    100M100P100Q192277F
  • License MIT

Find the an package.json in the path provided upwards

Package Exports

  • new-find-package-json
  • new-find-package-json/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (new-find-package-json) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

new-find-package-json

Inspired by find-package-json

This package can find (by default) the nearest package.json (upwards).

Usage

Sync:

const findFileFrom = process.cwd();
for (const file of findSync(findFileFrom)) {
  console.log("found file:", file);
}

Async/await (Promises):

const findFileFrom = process.cwd();
for await (const file of findAsync(findFileFrom)) {
  console.log("found file:", file);
}

Note: it is important to not forget to use for await..of instead of just for..of for findAsync

Options

Options for findSync & findAsync:

Index Name Type Default Description
0 input string none (required) The path to search from
1 base string process.cwd() The path to use as an absolute point if input is not absolute
2 fileName string package.json The Filename to search for

.next will return an object with value and done, where value is the absolute path to the file found and undefined if done is true