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

Updating cosmiconfig to not cache .js config files when told not to #5558

Merged
merged 6 commits into from Nov 29, 2018

Conversation

wuweiweiwu
Copy link
Contributor

@wuweiweiwu wuweiweiwu commented Nov 27, 2018

fixes: #5311

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory)
  • I’ve read the contributing guidelines.

Try the playground for this PR

@ikatyang
Copy link
Member

It seems Jest uses its own require (jestjs/jest#5120) which we're not able to test require's cache using Jest. I guess we could just update cosmiconfig without adding a test in this case.

@ikatyang ikatyang added this to the 1.15.3 milestone Nov 27, 2018
@SimenB
Copy link
Contributor

SimenB commented Nov 27, 2018

You can run jest.resetModules(), but I'm now sure how cosmiconfig caches. If it's just delete require.cache[thing] then it's always empty when running through Jest, so a resetModules should work

@ikatyang
Copy link
Member

I thought about it, but if Jest hold caches, the test will always be passed if we jest.resetModules() regardless the bug is fixed in cosmiconfig or not.

Ref: https://github.com/davidtheclark/cosmiconfig/pull/158/files#diff-e53a183cc3cc3a312532c73d45ca29cb

@SimenB
Copy link
Contributor

SimenB commented Nov 27, 2018

Ah, indeed.

I have some nefarious plans at some point to add support for require.cache properly (including delete, Proxy makes it quite straight forward), but it's super low pri at the moment

@j-f1 j-f1 changed the title Updating cosmic config to not cache .js config files when told not to Updating cosmiconfig to not cache .js config files when told not to Nov 27, 2018
@wuweiweiwu
Copy link
Contributor Author

removed the test!

@ikatyang ikatyang merged commit c28dc2f into prettier:master Nov 29, 2018
@ikatyang
Copy link
Member

Thanks!

@lock lock bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Feb 27, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Feb 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NodeJS API: Changes to .js config not being picked up due to NodeJS module caching
3 participants