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

find-cache-dir

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

find-cache-dir - npm Package Compare versions

Comparing version 3.3.2 to 4.0.0

29

index.js

@@ -1,7 +0,6 @@

'use strict';
const path = require('path');
const fs = require('fs');
const commonDir = require('commondir');
const pkgDir = require('pkg-dir');
const makeDir = require('make-dir');
import process from 'node:process';
import path from 'node:path';
import fs from 'node:fs';
import commonPathPrefix from 'common-path-prefix';
import {packageDirectorySync} from 'pkg-dir';

@@ -14,3 +13,3 @@ const {env, cwd} = process;

return true;
} catch (_) {
} catch {
return false;

@@ -22,3 +21,3 @@ }

if (options.create) {
makeDir.sync(directory);
fs.mkdirSync(directory, {recursive: true});
}

@@ -37,4 +36,4 @@

if (
!isWritable(nodeModules) &&
(fs.existsSync(nodeModules) || !isWritable(path.join(directory)))
!isWritable(nodeModules)
&& (fs.existsSync(nodeModules) || !isWritable(path.join(directory)))
) {

@@ -47,3 +46,3 @@ return;

module.exports = (options = {}) => {
export default function findCacheDirectory(options = {}) {
if (env.CACHE_DIR && !['true', 'false', '1', '0'].includes(env.CACHE_DIR)) {

@@ -56,6 +55,6 @@ return useDirectory(path.join(env.CACHE_DIR, options.name), options);

if (options.files) {
directory = commonDir(directory, options.files);
directory = commonPathPrefix(options.files.map(file => path.resolve(directory, file)));
}
directory = pkgDir.sync(directory);
directory = packageDirectorySync({cwd: directory});

@@ -68,6 +67,6 @@ if (!directory) {

if (!nodeModules) {
return undefined;
return;
}
return useDirectory(path.join(directory, 'node_modules', '.cache', options.name), options);
};
}
{
"name": "find-cache-dir",
"version": "3.3.2",
"version": "4.0.0",
"description": "Finds the common standard cache directory",
"license": "MIT",
"repository": "avajs/find-cache-dir",
"funding": "https://github.com/avajs/find-cache-dir?sponsor=1",
"repository": "sindresorhus/find-cache-dir",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=8"
"node": ">=14.16"
},
"scripts": {
"test": "xo && nyc ava"
"test": "xo && ava"
},

@@ -26,20 +33,14 @@ "files": [

"dependencies": {
"commondir": "^1.0.1",
"make-dir": "^3.0.2",
"pkg-dir": "^4.1.0"
"common-path-prefix": "^3.0.0",
"pkg-dir": "^7.0.0"
},
"devDependencies": {
"ava": "^2.4.0",
"coveralls": "^3.0.9",
"del": "^4.0.0",
"nyc": "^15.0.0",
"tempy": "^0.4.0",
"xo": "^0.25.3"
"ava": "^5.0.1",
"del": "^7.0.0",
"tempy": "^3.0.0",
"xo": "^0.52.4"
},
"nyc": {
"reporter": [
"lcov",
"text"
]
"ava": {
"workerThreads": false
}
}

@@ -1,2 +0,2 @@

# find-cache-dir [![Coverage Status](https://codecov.io/gh/avajs/find-cache-dir/branch/master/graph/badge.svg)](https://codecov.io/gh/avajs/find-cache-dir/branch/master)
# find-cache-dir

@@ -24,9 +24,7 @@ > Finds the common standard cache directory

If you decide to adopt this pattern, please file a PR adding your name to the list of adopters below.
## Install
```sh
npm install find-cache-dir
```
$ npm install find-cache-dir
```

@@ -36,5 +34,5 @@ ## Usage

```js
const findCacheDir = require('find-cache-dir');
import findCacheDirectory from 'find-cache-dir';
findCacheDir({name: 'unicorns'});
findCacheDirectory({name: 'unicorns'});
//=> '/user/path/node-modules/.cache/unicorns'

@@ -45,3 +43,3 @@ ```

### findCacheDir(options?)
### findCacheDirectory(options?)

@@ -115,13 +113,1 @@ Finds the cache directory using the supplied options. The algorithm checks for the `CACHE_DIR` environmental variable and uses it if it is not set to `true`, `false`, `1` or `0`. If one is not found, it tries to find a `package.json` file, searching every parent directory of the `cwd` specified (or implied from other options). It returns a `string` containing the absolute path to the cache directory, or `undefined` if `package.json` was never found or if the `node_modules` directory is unwritable.

- [More…](https://www.npmjs.com/browse/depended/find-cache-dir)
---
<div align="center">
<b>
<a href="https://tidelift.com/subscription/pkg/npm-find_cache-dir?utm_source=npm-find-cache-dir&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
</b>
<br>
<sub>
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
</sub>
</div>

Sorry, the diff of this file is not supported yet

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