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

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

wuweiweiwu added 2 commits Nov 27, 2018
@ikatyang

This comment has been minimized.

Copy link
Member

commented Nov 27, 2018

It seems Jest uses its own require (facebook/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

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Member

commented Nov 27, 2018

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

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor Author

commented Nov 27, 2018

removed the test!

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

8 of 10 checks passed

Header rules No header rules processed
Details
Pages changed 2 new files uploaded
Details
Mixed content No mixed content detected
Details
Redirect rules 3 redirect rules processed
Details
codecov/patch Coverage not affected when comparing bd38340...f8b7c22
Details
codecov/project 97.07% remains the same compared to bd38340
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
deploy/netlify Deploy preview ready!
Details
prettier.prettier Build #20181128.3 succeeded
Details
prod Workflow: prod
Details
@ikatyang

This comment has been minimized.

Copy link
Member

commented Nov 29, 2018

Thanks!

@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.
Projects
None yet
3 participants
You can’t perform that action at this time.