Socket
Socket
Sign inDemoInstall

new-find-package-json

Package Overview
Dependencies
2
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

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
444K
increased by2.66%
Maintainers
1
Install size
61.1 kB
Created
Weekly downloads
 

Changelog

Source

2.0.0 (2022-05-24)

⚠ BREAKING CHANGES

  • Typescript "target" is now "es2018", which is a breaking change, but should not affect anything as long as the required nodejs version is used (12.22 or higher)

Features

Readme

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

Last updated on 24 May 2022

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc