Commit bbc0d65
authored
[WTF-2256]: Throw non-empty directory error using preferred mechanism (#124)
#123 reported that the generator does not throw an understandable error
when the target directory is non-empty. A check for this already
existed, but the mechanism used for reporting the error no longer seems
to be supported by yeoman. This PR fixes the situation by throwing the
error instead, which is the preferred mechanism described in the yeoman
docs.
## Checklist
- Contains unit tests ❌
- Contains breaking changes ❌
- Did you update version and changelog? ✅
- PR title properly formatted (`[XX-000]: description`)? ✅ ❌
## This PR contains
- [x] Bug fix
- [ ] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Other (describe)
## What is the purpose of this PR?
To address the not understandable error reported by issue #123
## Relevant changes
Used a different mechanism for raising the error. The previous method
seems to have been an internal api that was not officially documented
but recommended on stack overflow.
## What should be covered while testing?
Try generating a widget in a directory that is not empty. I.e.:
```
# First check out this branch and run `npm install` inside the generator-widget package.
mkdir testWidget
touch testWidget/foo
yo /path/to/widgets-tools/packages/generator-widget/generators/app TestWidget
```4 files changed
Lines changed: 8 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
9 | 13 | | |
10 | 14 | | |
11 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
0 commit comments