Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

find-cache-dir

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

find-cache-dir

Finds the common standard cache directory

  • 3.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
42M
increased by5.55%
Maintainers
2
Weekly downloads
 
Created

What is find-cache-dir?

The find-cache-dir npm package is used to find a directory to use for storing cache files. It is commonly used in tools that perform some form of compilation or data processing and need a place to store cache files to speed up future runs. The package helps to locate a suitable directory following conventions and best practices for cache storage.

What are find-cache-dir's main functionalities?

Finding a cache directory

This feature allows you to find a cache directory for your application or module. You provide an options object with a 'name' property, and it returns a path to the cache directory.

const findCacheDir = require('find-cache-dir');

const cacheDir = findCacheDir({ name: 'my-app' });
console.log(cacheDir); // Outputs a directory path like '/path/to/cache/directory/my-app'

Creating a cache directory

In addition to finding the cache directory, you can also ensure that it is created if it does not already exist by setting the 'create' option to true.

const findCacheDir = require('find-cache-dir');

const cacheDir = findCacheDir({ name: 'my-app', create: true });
console.log(cacheDir); // Outputs a directory path and ensures that the directory exists

Using a custom directory

You can specify a custom directory to use as the base for your cache directory with the 'cwd' option. This allows you to control where the cache directory is located.

const findCacheDir = require('find-cache-dir');

const cacheDir = findCacheDir({ name: 'my-app', cwd: '/custom/directory' });
console.log(cacheDir); // Outputs a directory path within the specified custom directory

Theming cache directory

You can make the cache directory unique to a set of files by providing an array of file paths with the 'files' option. This is useful when the cache should be invalidated based on changes to specific files.

const findCacheDir = require('find-cache-dir');

const cacheDir = findCacheDir({ name: 'my-app', files: ['file.js'] });
console.log(cacheDir); // Outputs a directory path that is unique to the array of file paths provided

Other packages similar to find-cache-dir

Keywords

FAQs

Package last updated on 09 Apr 2019

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc