Socket
Socket
Sign inDemoInstall

fs-exists-sync

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    fs-exists-sync

Drop-in replacement for `fs.existsSync` with zero dependencies. Other libs I found either have crucial differences from fs.existsSync, or unnecessary dependencies. See README.md for more info.


Version published
Maintainers
1
Install size
6.70 kB
Created

Readme

Source

fs-exists-sync NPM version NPM downloads Build Status

Drop-in replacement for fs.existsSync with zero dependencies. Other libs I found either have crucial differences from fs.existsSync, or unnecessary dependencies. See README.md for more info.

Install

Install with npm:

$ npm install fs-exists-sync --save

Usage

var exists = require('fs-exists-sync');

console.log(exists('.'));
//=> true
console.log(exists(process.cwd()));
//=> true
console.log(exists('README.md'));
//=> true
console.log(exists('foo.txt'));
//=> false
console.log(exists(''));
//=> false
console.log(exists());
//=> false

Why another "exists" lib?

I just want a simple replacement for fs.existsSync. Here is what I found:

  • path-exists: Has dependencies to support a promises API
  • fs-exists: async only
  • file-exists: returns false if the path exists but is a directory.
  • exists: nothing to do with fs.

API

You might also be interested in these projects:

  • is-absolute: Polyfill for node.js path.isAbolute. Returns true if a file path is absolute. | homepage
  • parse-filepath: Pollyfill for node.js path.parse, parses a filepath into an object. | homepage
  • try-open: Tries to open a file using fs.openSync (only necessary with sync), fails gracefully if the… more | homepage

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Building docs

Generate readme and API documentation with verb:

$ npm install verb && npm run docs

Or, if verb is installed globally:

$ verb

Running tests

Install dev dependencies:

$ npm install -d && npm test

Author

Jon Schlinkert

License

Copyright © 2016, Jon Schlinkert. Released under the MIT license.


This file was generated by verb, v0.9.0, on April 09, 2016.

Keywords

FAQs

Last updated on 09 Apr 2016

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