Skip to main content

Module utils

Module utils 

Source

Constants§

CACHE_MANIFEST_NAME
CACHE_MANIFEST_SIG
LOG_FILE
NPM_INSTALL_TIMEOUT_SECS
NPM_SHOW_TIMEOUT_SECS

Functions§

cache_clean
Remove all cached tarballs (store + legacy). Keeps logs.
cache_export
Export cache entries needed for current project (package.json + lockfile) into dir. Writes manifest.json for import. Returns number of files copied.
cache_import
Import tarballs from dir into cache. Expects manifest.json (from cache export) or .tgz files named pkg-version.tgz. Returns number of packages imported.
cache_package_tarballDeprecated
Store a package in the cache (content-addressable + legacy path). Prefer registry::fill_store_from_registry (no npm subprocess). Kept for legacy callers.
cache_prune
Prune cache: remove store tarballs not referenced by index. If keep_recent is Some(N), keep only N most recently used (by mtime).
cache_size_bytes
Return (total size in bytes, count of tarballs) for the cache (store + legacy .tgz in root).
content_hash
SHA256 hash of file (hex)
format_cache_name
get_cache_dir
Returns the path to the cache directory. Uses JHOL_CACHE_DIR if set; otherwise Windows: %USERPROFILE%.jhol-cache, Unix: $HOME/.jhol-cache
get_cached_tarball
Returns the path to a cached tarball if present.
init_cache
is_package_cached
link_package_from_store
Create node_modules/<package_name> as a symlink (Unix) or directory junction (Windows) to store path. For scoped packages, creates node_modules/@scope/ and links pkg there. Returns Err if JHOL_LINK=0 or link creation fails (caller should fall back to copy).
list_cached_packages
List all cached package tarballs (pkg@version or legacy base names)
lockfile_content_hash
SHA256 hash of lockfile content for CI cache key. Prefers bun.lock then package-lock.json.
log
log_error
manifest_signature
npm_install_timeout
Run npm install with timeout
read_store_index
run_command_timeout
Run a command with a timeout. On timeout the process is killed and an error is returned.
store_unpacked_dir
Unpacked store dir: cache_dir/store_unpacked// (one dir per tarball hash).
verify_manifest_signature
verify_sri
Verify file against SRI string (e.g. “sha512-”). Returns true if match.
write_store_index