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

exists-file

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

exists-file

Check if a file exists. A fs.exists implementation that is not deprecated.

  • 3.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7.4K
increased by35.02%
Maintainers
1
Weekly downloads
 
Created
Source

exists-file

Last version Build Status Coverage Status Dependency status Dev Dependencies Status NPM Status Donate

Check if a file exists. A fs.exists implementation that is not deprecated.

Because fs.exist and fs.existsSync are deprecated this an implementation using fs.stats and fs.statsSync for get the same result.

Also always keep in mind:

fs.exists() should not be used to check if a file exists before calling fs.open(). Doing so introduces a race condition since other processes may change the file's state between the two calls. Instead, user code should call fs.open() directly and handle the error raised if the file is non-existent.

Install

npm install exists-file --save

Usage

var existsFile = require('exists-file')

// async with a callback
existsFile('./README.md', console.log) // => null, true

// async with a promise
existsFile('./README.md').then(console.log).catch(console.error) // => true

// sync
var exists = existsFile.sync('./README.md')
console.log(exists) // => true

API

existsFile(filepath, [cb])

filepath

Required
Type: string

The relative or absolute file path.

cb

Type: function

If cb is not provided then it returns a promise.

existsFile.sync(filepath)

filepath

Required
Type: string

The relative or absolute file path.

License

MIT © Kiko Beats

Keywords

FAQs

Package last updated on 18 Jul 2017

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