Skip to content

Commit 6a378f5

Browse files
authoredAug 29, 2021
Respect name option when CACHE_DIR environment variable is set (#34)
1 parent 05a0b08 commit 6a378f5

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed
 

‎index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function getNodeModuleDirectory(directory) {
4343

4444
module.exports = (options = {}) => {
4545
if (env.CACHE_DIR && !['true', 'false', '1', '0'].includes(env.CACHE_DIR)) {
46-
return useDirectory(path.join(env.CACHE_DIR, 'find-cache-dir'), options);
46+
return useDirectory(path.join(env.CACHE_DIR, options.name), options);
4747
}
4848

4949
let {cwd: directory = cwd()} = options;

‎test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ test('returns undefined if it can\'t find package.json', t => {
4343

4444
test('supports CACHE_DIR environment variable', t => {
4545
const newCacheDirectory = tempDirectory();
46-
const finalDirectory = path.join(newCacheDirectory, 'find-cache-dir');
46+
const finalDirectory = path.join(newCacheDirectory, 'some-package');
4747
process.env.CACHE_DIR = newCacheDirectory;
4848

49-
t.is(findCacheDir(), finalDirectory);
49+
t.is(findCacheDir({name: 'some-package'}), finalDirectory);
5050

51-
findCacheDir({create: true});
51+
findCacheDir({name: 'some-package', create: true});
5252
t.true(fs.existsSync(finalDirectory));
5353

54-
const thunk = findCacheDir({thunk: true});
54+
const thunk = findCacheDir({name: 'some-package', thunk: true});
5555
t.is(thunk('foo'), path.join(finalDirectory, 'foo'));
5656
t.is(thunk('bar'), path.join(finalDirectory, 'bar'));
5757

0 commit comments

Comments
 (0)
Please sign in to comment.