Skip to content

Conversation

@weirdwater
Copy link
Collaborator

#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

  • 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

The error was reported using a mechanism that no longer seems to be
supported by yeoman. Throwing an error seems to be the preferred method
now.
@LEGIO-SEXTA-FERRATA
Copy link
Contributor

The title format we follow in this GitHub repository -as opposed to the AppDev repo on GitLab- has a quirk. There should be a colon (:) after the brackets pointing to the JIRA issue.

As you can also see, this is extremely minor. I would be okay if you didn't bother with it. But just wanted to mention as a reminder for future PRs.

Copy link
Contributor

@LEGIO-SEXTA-FERRATA LEGIO-SEXTA-FERRATA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few comments. But nevertheless, approving this PR. As the issues are quite minor, it's okay if you don't want to bother.

If you want to do them, I'll re-approve later. 👍

@weirdwater weirdwater changed the title [WTF-2256] Throw non-empty directory error using preferred mechanism [WTF-2256]: Throw non-empty directory error using preferred mechanism May 12, 2025
@weirdwater weirdwater enabled auto-merge May 12, 2025 11:33
@weirdwater weirdwater merged commit bbc0d65 into master May 12, 2025
7 checks passed
@weirdwater weirdwater deleted the wtf/123-non-empty-dir branch May 12, 2025 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants