Skip to content

Commit 0bc30bd

Browse files
committedFeb 22, 2020
Minor tweaks
1 parent 71faea2 commit 0bc30bd

File tree

4 files changed

+18
-20
lines changed

4 files changed

+18
-20
lines changed
 

‎index.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ const commonDir = require('commondir');
55
const pkgDir = require('pkg-dir');
66
const makeDir = require('make-dir');
77

8-
const {env} = process;
9-
108
const isWritable = path => {
119
try {
1210
fs.accessSync(path, fs.constants.W_OK);
@@ -42,24 +40,26 @@ function getNodeModuleDirectory(directory) {
4240
}
4341

4442
module.exports = (options = {}) => {
45-
if (env.CACHE_DIR) {
46-
return useDirectory(path.join(env.CACHE_DIR, 'find-cache-dir'), options);
43+
if (process.env.CACHE_DIR) {
44+
return useDirectory(path.join(process.env.CACHE_DIR, 'find-cache-dir'), options);
4745
}
4846

49-
let directory = options.cwd || process.cwd();
47+
let {cwd: directory = process.cwd()} = options;
5048

5149
if (options.files) {
5250
directory = commonDir(directory, options.files);
5351
}
5452

5553
directory = pkgDir.sync(directory);
5654

57-
if (directory) {
58-
const nodeModules = getNodeModuleDirectory(directory);
59-
if (!nodeModules) {
60-
return undefined;
61-
}
55+
if (!directory) {
56+
return;
57+
}
6258

63-
return useDirectory(path.join(directory, 'node_modules', '.cache', options.name), options);
59+
const nodeModules = getNodeModuleDirectory(directory);
60+
if (!nodeModules) {
61+
return undefined;
6462
}
63+
64+
return useDirectory(path.join(directory, 'node_modules', '.cache', options.name), options);
6565
};

‎license

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) James Talmage <james@talmage.io> (github.com/jamestalmage)
3+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
66

‎package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@
2424
],
2525
"dependencies": {
2626
"commondir": "^1.0.1",
27-
"make-dir": "^3.0.0",
27+
"make-dir": "^3.0.2",
2828
"pkg-dir": "^4.1.0"
2929
},
3030
"devDependencies": {
3131
"ava": "^2.4.0",
3232
"coveralls": "^3.0.9",
3333
"del": "^4.0.0",
34-
"nyc": "^14.1.1",
34+
"nyc": "^15.0.0",
3535
"tempy": "^0.4.0",
3636
"xo": "^0.25.3"
3737
},

‎readme.md

+4-6
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@ findCacheDir({name: 'unicorns'});
3838
//=> '/user/path/node-modules/.cache/unicorns'
3939
```
4040

41-
42-
## Tips
43-
44-
- To test modules using `find-cache-dir`, set the `CACHE_DIR` environmental variable to temporarily override the directory that is resolved.
45-
46-
4741
## API
4842

4943
### findCacheDir(options?)
@@ -103,6 +97,10 @@ thunk('baz', 'quz.js')
10397

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

100+
## Tips
101+
102+
- To test modules using `find-cache-dir`, set the `CACHE_DIR` environment variable to temporarily override the directory that is resolved.
103+
106104
## Adopters
107105

108106
- [`AVA`](https://ava.li)

0 commit comments

Comments
 (0)
Please sign in to comment.