Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect name option when CACHE_DIR environment variable is set #34

Merged
merged 1 commit into from
Aug 29, 2021

Conversation

alexanderGerbik
Copy link
Contributor

No description provided.

@alexanderGerbik
Copy link
Contributor Author

@sindresorhus Whom shall I ask for a review?

index.js Outdated
@@ -43,7 +43,7 @@ function getNodeModuleDirectory(directory) {

module.exports = (options = {}) => {
if (env.CACHE_DIR && !['true', 'false', '1', '0'].includes(env.CACHE_DIR)) {
return useDirectory(path.join(env.CACHE_DIR, 'find-cache-dir'), options);
return useDirectory(path.join(env.CACHE_DIR, options.name || 'find-cache-dir'), options);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The || is moot as the name option is documented as "required".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return useDirectory(path.join(env.CACHE_DIR, options.name || 'find-cache-dir'), options);
return useDirectory(path.join(env.CACHE_DIR, options.name), options);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why is was set to find-cache-dir in the first place, appears to be an error that was never caught by the unit tests since the code was never tested under a different package name.

@sindresorhus
Copy link
Owner

// @Richienb

test.js Outdated
delete process.env.CACHE_DIR;
});

test('respects options.name when CACHE_DIR is set', t => {
const newCacheDirectory = tempDirectory();
const finalDirectory = path.join(newCacheDirectory, 'babel-loader');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small nitpick: Might be best to use a more generic package name for posterity.

@sindresorhus sindresorhus merged commit 6a378f5 into sindresorhus:master Aug 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants