NPM.Cache (NPM v0.6.0)

Copy Markdown View Source

Global package cache.

Downloaded packages are stored in ~/.npm_ex/cache/<name>/<version>/ and reused across projects. The cache is populated on first install and checked before downloading from the registry.

Summary

Functions

Check if a package version is already cached.

Root directory of the global cache.

Ensure a package version is in the cache.

Path to a specific package version in the cache.

Functions

cached?(name, version)

@spec cached?(String.t(), String.t()) :: boolean()

Check if a package version is already cached.

dir()

@spec dir() :: String.t()

Root directory of the global cache.

ensure(name, version, tarball_url, integrity, opts \\ [])

@spec ensure(String.t(), String.t(), String.t(), String.t(), keyword()) ::
  {:ok, String.t()} | {:ok, :missing_optional} | {:error, term()}

Ensure a package version is in the cache.

Downloads and extracts the tarball if not already cached. Returns {:ok, cache_path}, {:ok, :missing_optional} when an optional package fails to fetch, or {:error, reason}.

package_dir(name, version)

@spec package_dir(String.t(), String.t()) :: String.t()

Path to a specific package version in the cache.