Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

locate-path

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

locate-path

Get the first path that exists on disk of multiple paths

  • 7.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
143M
increased by1.37%
Maintainers
1
Weekly downloads
 
Created

What is locate-path?

The locate-path npm package is designed to find a file or directory by looking for it in multiple paths. It is useful for situations where you need to locate a file but are unsure of its exact location within a list of possible directories. It can be used synchronously or asynchronously and supports both promises and async/await syntax.

What are locate-path's main functionalities?

Asynchronous Path Location

This feature allows you to asynchronously locate a file or directory from an array of paths. The first path that contains the file or directory is returned.

const locatePath = require('locate-path');

(async () => {
  const foundPath = await locatePath(['unicorn.png', 'rainbow.png'], {cwd: 'images'});
  console.log(foundPath);
  //=> 'images/unicorn.png'
})();

Synchronous Path Location

This feature provides a synchronous way to locate a file or directory from an array of paths. It is useful when you need to find a path in a blocking manner.

const locatePath = require('locate-path');

const foundPath = locatePath.sync(['unicorn.png', 'rainbow.png'], {cwd: 'images'});
console.log(foundPath);
//=> 'images/unicorn.png'

Other packages similar to locate-path

Keywords

FAQs

Package last updated on 09 Feb 2023

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