Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
resolve-package-path
Advanced tools
Readme
This project is special-purpose, made to resolve package.json
files for:
It cannot and does not resolve anything else.
To achieve its file-resolution performance, it does two specific things:
It memoizes results identically to node's require
. Specifically,
for a given moduleName and baseDir it will, for the duration of the process,
always return the exact same response.
It re-implements the parts of require.resolve
needed to resolve package.json
files ONLY. This removes unneeded I/O. (based on @davecombs approach)
yarn add resolve-package-path
const resolvePackagePath = require('resolve-package-path');
resolvePackagePath('rsvp', 'base-dir/to/start/the/node_resolution-algorithm-from') // => /path/to/rsvp.json or null
const { findUpPackagePath } = resolvePackagePath;
findUpPackagePath('base-dir/to/start') // => path/to/package.json or null
Node supports --preserve-symlinks
and NODE_PRESERVE_SYMLINKS=1
for compatibility this library respects these.
Although by default resolve-package-path
caches or memoizes results, this feature can be disabled:
const resolvePackagePath = require('resolve-package-path');
resolvePackagePath('rsvp', 'base-dir/to/start/the/node_resolution-algorithm-from', false) // => uncached result /path/to/rsvp.json or null
const { findUpPackagePath } = resolvePackagePath;
findUpPackagePath('base-dir/to/start', false) // => path/to/package.json or null
const resolvePackagePath = require('resolve-package-path');
resolvePackagePath._resetCache();
In some advanced circumtances, you may want to gain access to the cache to share between more systems. In that case, a cache instance of the following form can be provided as a third argument:
cache = {
RESOLVED_PACKAGE_PATH: new Map(),
REAL_FILE_PATH: new Map(),
REAL_DIRECTORY_PATH: new Map(),
};
findUpCache = new Map();
const resolvePackagePath = require('resolve-package-path');
resolvePackagePath('rsvp', 'path/to/start/from', cache);
const { findUpPackagePath } = resolvePackagePath;
findUpPackagePath('base-dir/to/start', findUpCache) // => path/to/package.json or null
For consumers who also do getRealFilePath
or
getRealDirectoryPath
calls on relevant paths, we expose them as utilities.
These utilties ensure identical functionality to resolve-package-path, and a
shared cache, which may help reduce IO.
FAQs
a special purpose fast memoizing way to resolve a node modules package.json
The npm package resolve-package-path receives a total of 1,168,650 weekly downloads. As such, resolve-package-path popularity was classified as popular.
We found that resolve-package-path demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.