Skip to content

Commit bbc0d65

Browse files
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 ```
2 parents 2d20eaf + f45d2a4 commit bbc0d65

4 files changed

Lines changed: 8 additions & 4 deletions

File tree

packages/generator-widget/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## [Unreleased]
88

9+
### Fixed
10+
11+
- We fixed the error message when attempting to generate a widget in a non-empty directory. (Issue #123)
12+
913
## [10.15.0] - 2024-09-24
1014

1115
### Changed

packages/generator-widget/generators/app/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class MxGenerator extends Generator {
3232

3333
if ((await dirExists(fullDestinationPath)) && !(await isDirEmpty(fullDestinationPath))) {
3434
this.log(text.BANNER);
35-
this.env.error(Error(text.DIR_NOT_EMPTY_ERROR));
35+
throw new Error(text.DIR_NOT_EMPTY_ERROR);
3636
}
3737
}
3838

packages/generator-widget/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/generator-widget/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@mendix/generator-widget",
3-
"version": "10.15.0",
3+
"version": "10.15.1",
44
"description": "Mendix Pluggable Widgets Generator",
55
"engines": {
66
"node": ">=16"

0 commit comments

Comments
 (0)