-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
fix(coverage): prevent reportsDirectory
from removing user's project
#5376
fix(coverage): prevent reportsDirectory
from removing user's project
#5376
Conversation
✅ Deploy Preview for fastidious-cascaron-4ded94 canceled.
|
57a67f2
to
0012cec
Compare
const reportsDirectory = resolve(resolved.root, resolved.coverage.reportsDirectory) | ||
|
||
if (reportsDirectory === resolved.root || reportsDirectory === process.cwd()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe check also parent directory like ../
?
Using root.startsWith(reportsDirectory)
can cover root === reportsDirectory
as a special case.
(Ah, I guess startsWith
might not be it since "/some/directory".startsWith("/some/dir")
is a false positive.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can check startsWith(reportsDirectory + '/')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. We can also add this improvement later on if you want to include this PR as is in the release @sheremet-va.
Description
Configuration below can remove user's whole project including local Git history from
.git
. One could accidentally use that when trying to generate coverage reports in the root of project instead of the default./coverage
, and find out that their whole project is now wiped (that's me 🙃).Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yaml
unless you introduce a new test example.Tests
pnpm test:ci
.Documentation
pnpm run docs
command.Changesets
feat:
,fix:
,perf:
,docs:
, orchore:
.