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

[regression] find-cache-dir 3.3.0, used through nyc+mocha, causes creation of a folder tree ./false/find-cache-dir/ containing js files #26

Closed
ronjouch opened this issue Mar 6, 2020 · 5 comments · Fixed by #27

Comments

@ronjouch
Copy link

ronjouch commented Mar 6, 2020

I have a Mocha test suite, code-coveraged by Nyc, run inside Shippable CI with the following command: NODE_ENV=test nyc --reporter=cobertura --report-dir=../shippable/codecoverage/ mocha --exit --require ./config/mocha.js --recursive test --timeout 80000 --ui bdd -R xunit --reporter-options output=../shippable/testresults/maestro.xml .

  • Using find-cache-dir@3.2.0, tests pass and no folder is created in cwd.
  • After re-creating my project's package-lock.json, I got find-cache-dir@3.3.0 (which makes semver sense, since nyc 15.0.0 depends on "find-cache-dir": "^3.2.0"), tests pass, but running the tests now cause creation of a spurious folder named false, itself containing a folder named find-cache-dir, containing js named <myOriginalFilename>-<some kind of hash>.js:
false/find-cache-dir/fields-9e2a8b3608c81ff79e5dab523ca0a8c95035eaa14ec95ca88bdc922d0a8e8666.js
false/find-cache-dir/config-a10b75b822f09c2a3fe51c8f4ab42b7a09609eb1a9c065eeb30f475f7049dc2c.js
false/find-cache-dir/index-21c01eca85d0b02b6011525dd4934129ef0384a5aaf6e5a7989eb7c43db9f5e3.js
... [59 other files]
  • After manually reverting only find-cache-dir to 3.2.0 in the package-lock (editing the package lock to use the old version & hash), the problem disappears.

I cannot reproduce the issue on my local dev. machine, the issue only arises on Shippable CI. I don't know why yet.

The project uses a package-lock, guaranteeing the only difference is the find-cache-dir version. So, the regression must lie in v3.2.0...v3.3.0 .

Node 12.15.0, Nyc 15.0.0, Mocha 7.1.0. Project is closed source and I cannot share it, sorry. I hope the regression window is enough to find a fix, as I'm unable to reproduce the issue locally and it would be difficult for me to provide a minimal & reliably-reproducible test case.

Thanks.

@sindresorhus
Copy link
Owner

// @Richienb

@Richienb
Copy link
Contributor

Richienb commented Mar 6, 2020

@ronjouch In your environment, what is process.env.CACHE_DIR set to?

@ronjouch
Copy link
Author

ronjouch commented Mar 7, 2020

In your environment, what is process.env.CACHE_DIR set to?

@Richienb oh wow. This is a beautiful bug 😄. Good catch, you're right. In Shippable CI, CACHE_DIR is by default set to false. See Shippable docs - Environment variables - Standard variables:

CACHE_DIR If cache is true in the build section of shippable.yml, then true. Otherwise false.

→ Given this is a still a very new feature: with appropriate communication to initial users and a major semver break, would a less collision-prone env. var (e.g. FIND_CACHE_DIR) make sense?

@Richienb
Copy link
Contributor

Richienb commented Mar 7, 2020

@sindresorhus

@sindresorhus
Copy link
Owner

I think we should just gracefully handle this. If the value is true/false/1/0, we don’t use the environment variable.

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 a pull request may close this issue.

3 participants