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.promises.exists
Advanced tools
The missing fs.promises.exists()
. Also supports case-sensitive/insensitive file paths.
If you like this project, please star it & follow me to see what other cool projects I'm working on! ❤️
The fs Promises API doesn't have an exists()
method that replaces existsSync()
.
Depending on how the file-system is configured, file paths can be case-sensitive or insensitive. This module lets you specify case regardless of the file-system configuration.
npm i fs.promises.exists
import fsExists from 'fs.promises.exists'
await fsExists('./file-that-exists')
// => true
await fsExists('./file-that-doesnt-exist')
// => false
import fsExists from 'fs.promises.exists'
await fsExists('./CASE-SENSITIVE-FILE-PATH', true)
// => true
await fsExists('./case-sensitive-file-path', true)
// => false
import fsExists from 'fs.promises.exists'
await fsExists('./CASE-SENSITIVE-FILE-PATH', false)
// => ./CASE-SENSITIVE-FILE-PATH ← Retruns truthy case-preserved match
await fsExists('./case-sensitive-file-path', false)
// => ./CASE-SENSITIVE-FILE-PATH ← Retruns truthy case-preserved match
Returns: boolean | string
Type: string
Required
Path to the file to check the existence of.
Type: boolean
Optional
Whether to check the existence of the path case-sensitively or not.
true
- Enforce case sensitive path checking.
false
- Enforce case insensitive path checking. On match, it returns the case senstive path as a string.
undefined
- Default behavior is based on the disk formatting of the environment. Specifically, this is the HFS+ file system personality.
Most default setups (such as macOS) defaults to being case insensitive. That means checking whether ./does-file-exist
and ./DoEs-FiLe-ExIsT
are equivalent.
FAQs
The missing fs.promises.exists()
We found that fs.promises.exists 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.