Skip to content

Commit

Permalink
Meta tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Dec 12, 2019
1 parent a2679d9 commit a0c487f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
1 change: 1 addition & 0 deletions .travis.yml
@@ -1,5 +1,6 @@
language: node_js
node_js:
- '12'
- '10'
- '8'
after_script:
Expand Down
9 changes: 5 additions & 4 deletions index.js
Expand Up @@ -28,10 +28,11 @@ module.exports = (options = {}) => {

if (directory) {
const nodeModules = path.join(directory, 'node_modules');
if (!isWritable(nodeModules)) {
if (fs.existsSync(nodeModules) || !isWritable(path.join(directory))) {
return undefined;
}
if (
!isWritable(nodeModules) &&
(fs.existsSync(nodeModules) || !isWritable(path.join(directory)))
) {
return undefined;
}

directory = path.join(directory, 'node_modules', '.cache', name);
Expand Down
9 changes: 5 additions & 4 deletions package.json
Expand Up @@ -4,6 +4,7 @@
"description": "Finds the common standard cache directory",
"license": "MIT",
"repository": "avajs/find-cache-dir",
"funding": "https://github.com/avajs/find-cache-dir?sponsor=1",
"engines": {
"node": ">=8"
},
Expand All @@ -27,11 +28,11 @@
"pkg-dir": "^4.1.0"
},
"devDependencies": {
"ava": "^1.3.1",
"coveralls": "^3.0.3",
"ava": "^2.4.0",
"coveralls": "^3.0.9",
"del": "^4.0.0",
"nyc": "^13.3.0",
"xo": "^0.24.0"
"nyc": "^14.1.1",
"xo": "^0.25.3"
},
"nyc": {
"reporter": [
Expand Down
13 changes: 4 additions & 9 deletions readme.md
Expand Up @@ -23,14 +23,12 @@ rm -rf ./node_modules/.cache

If you decide to adopt this pattern, please file a PR adding your name to the list of adopters below.


## Install

```
$ npm install find-cache-dir
```


## Usage

```js
Expand All @@ -40,7 +38,6 @@ findCacheDir({name: 'unicorns'});
//=> '/user/path/node-modules/.cache/unicorns'
```


## API

### findCacheDir(options?)
Expand All @@ -53,7 +50,7 @@ Type: `object`

##### name

*Required*<br>
*Required*\
Type: `string`

Should be the same as your project name in `package.json`.
Expand All @@ -66,21 +63,21 @@ An array of files that will be searched for a common parent directory. This comm

##### cwd

Type: `string`<br>
Type: `string`\
Default `process.cwd()`

Directory to start searching for a `package.json` from.

##### create

Type: `boolean`<br>
Type: `boolean`\
Default `false`

If `true`, the directory will be created synchronously before returning.

##### thunk

Type: `boolean`<br>
Type: `boolean`\
Default `false`

If `true`, this modifies the return type to be a function that is a thunk for `path.join(theFoundCacheDirectory)`.
Expand All @@ -100,7 +97,6 @@ thunk('baz', 'quz.js')

This is helpful for actually putting actual files in the cache!


## Adopters

- [`AVA`](https://ava.li)
Expand All @@ -111,7 +107,6 @@ This is helpful for actually putting actual files in the cache!
- [`Phenomic`](https://phenomic.io)
- [`javascripthon-loader`](https://github.com/Beg-in/javascripthon-loader)


---

<div align="center">
Expand Down

0 comments on commit a0c487f

Please sign in to comment.