Socket
Socket
Sign inDemoInstall

new-find-package-json

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

new-find-package-json

Find the an package.json in the path provided upwards


Version published
Weekly downloads
554K
increased by5.57%
Maintainers
1
Weekly downloads
 
Created
Source

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:

IndexNameTypeDefaultDescription
0inputstringnone (required)The path to search from
1basestringprocess.cwd()The path to use as an absolute point if input is not absolute
2fileNamestringpackage.jsonThe 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

Keywords

FAQs

Package last updated on 24 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc