Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
fs-exists-sync
Advanced tools
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.
The fs-exists-sync npm package provides a simple and synchronous way to check if a file or directory exists in the filesystem. It is a lightweight utility that wraps around the Node.js fs module's synchronous methods to offer a straightforward API for existence checks.
Check if a file exists
This feature allows you to check if a specific file exists at the given path. The function returns a boolean value indicating the existence of the file.
const exists = require('fs-exists-sync');
const fileExists = exists('path/to/file.txt');
console.log(fileExists); // true or false
Check if a directory exists
This feature allows you to check if a specific directory exists at the given path. The function returns a boolean value indicating the existence of the directory.
const exists = require('fs-exists-sync');
const dirExists = exists('path/to/directory');
console.log(dirExists); // true or false
fs-extra is a popular package that extends the native Node.js fs module with additional methods, including both synchronous and asynchronous versions of file and directory existence checks. It offers more functionality compared to fs-exists-sync, such as copying, moving, and removing files and directories.
path-exists is another package that provides a simple way to check if a path exists. Unlike fs-exists-sync, path-exists offers asynchronous methods, making it more suitable for non-blocking operations in Node.js applications.
file-exists is a package that provides both synchronous and asynchronous methods to check if a file exists. It is similar to fs-exists-sync but offers more flexibility with its asynchronous API.
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 with npm:
$ npm install fs-exists-sync --save
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
I just want a simple replacement for fs.existsSync
. Here is what I found:
false
if the path exists but is a directory.fs
.You might also be interested in these projects:
path.isAbolute
. Returns true if a file path is absolute. | homepagepath.parse
, parses a filepath into an object. | homepagePull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Generate readme and API documentation with verb:
$ npm install verb && npm run docs
Or, if verb is installed globally:
$ verb
Install dev dependencies:
$ npm install -d && npm test
Jon Schlinkert
Copyright © 2016, Jon Schlinkert. Released under the MIT license.
This file was generated by verb, v0.9.0, on April 09, 2016.
FAQs
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.
The npm package fs-exists-sync receives a total of 1,763,790 weekly downloads. As such, fs-exists-sync popularity was classified as popular.
We found that fs-exists-sync demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.