feat: added home check and --skip-home-check to set version
What's the problem this PR addresses?
Users should be blocked from accidentally running yarn set version from the home directory (~). This adds an error to that case unless a new --skip-home-check is specified.
Resolves #4426.
How did you fix it?
Checks this.context.cwd against homedir() at the beginning of the execute() method.
I'm not confident I answered correctly on the version updates. 🤷
Testing: I couldn't find any unit tests for version.ts, and it seems risky to run acceptance tests in the user's home directory. Is there a testing strategy this PR should go with? Help please?
Checklist
- [x] I have read the Contributing Guide.
- [x] I have set the packages that need to be released for my changes to be effective.
- [x] I will check that all automated PR checks pass before the PR gets reviewed.
Co-authored-by: @nikstern [email protected]
until fixed (by perhaps 2023?)
Please learn how to interact professionally on open-source repositories. Being snarky makes me less likely to care about whatever problem you have and I don't have. Don't abuse our will to help.
The problem is also wider than this codebase; the global Yarn is supposed to be Yarn 1.x, so running yarn set version from the home folder will lead to code being evaluated by Yarn 1, ie a different codebase. This PR alone won't fix the root issue.
I ran into the same issue with even the latest version (3.6.0), any updates on this? I'm using macOS Ventura