
Security News
npm ‘is’ Package Hijacked in Expanding Supply Chain Attack
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
path-resolver
Advanced tools
returns a valid filesystem path.
New stuff:
process.cwd()
if they aren't absolute pathsthis is a really insanely simple module to do path normalization, and existence checking. How simple? <30 lines of coffeescript.
npm install path-resolver
and then require('path-resolver').<method>
where method is guess
,sync
, or async
.
sync check (existential checking is done, in sync)
if ((path = require('path-resolver').sync("/path/to/file.ext")) != false)
console.log("valid path given: "+path);
async check (existential checking is done, async [needs callback])
require('path-resolver').async("/path/to/file.ext",function(path){
if (path != false)
console.log("valid path given: "+path);
else
console.log("bad path!");
});
and guess check (no existential checks done)
if ((path = require('path-resolver').guess("/path/to/file.ext")) != false)
console.log("probably valid path given (syntax is correct): "+path);
so a sync check uses fs.existsSync
whereas async uses fs.exists
. guess does check at all, just syntax verifies the path.
if any of these methods return false, the path syntax was invalid, or (if using sync or async) the path doesn't exist in the filesystem.
FAQs
returns a valid filesystem path.
We found that path-resolver 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
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
Security News
A critical flaw in the popular npm form-data package could allow HTTP parameter pollution, affecting millions of projects until patched versions are adopted.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.