Socket
Socket
Sign inDemoInstall

@kwsites/file-exists

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kwsites/file-exists

Synchronous validation of a path existing either as a file or as a directory.


Version published
Weekly downloads
3.1M
decreased by-18.78%
Maintainers
1
Weekly downloads
 
Created
Source

@kwsites/file-exists

Synchronous validation of a path existing either as a file or as a directory.

const { exists, FILE, FOLDER, READABLE } = require('@kwsites/file-exists');

// check for a folder existing
assert(exists(__dirname, FOLDER));
assert(!exists(__filename, FOLDER));

// check for a file existing
assert(!exists(__filename, FILE));
assert(exists(__filename, FILE));

// when no type is specified, both folders and files are allowed
assert(exists(__dirname));
assert(exists(__filename));

// alternatively specify both files and folders
assert(exists(__dirname, FILE + FOLDER));

// or just that the path is readable (can be either a file or folder)
assert(exists(__filename, READABLE));

Troubleshooting

This library uses debug to handle logging, to enable logging, use either the environment variable:

"DEBUG=@kwsites/file-exists" node ./your-app.js 

Or explicitly enable logging using the debug library itself:

require('debug').enable('@kwsites/file-exists');

FAQs

Package last updated on 10 Jun 2020

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