Skip to content
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

feat: enable noOverwriteGlobs for templates based on react engine #1234

Merged

Conversation

lmgyuan
Copy link
Collaborator

@lmgyuan lmgyuan commented Jul 30, 2024

Description
Description

add noOverwriteGlobs parameters to methods saveContentToFile and saveRenderedReactContent
pass this.noOverwriteGlobs to saveContentToFile
check the name of file to be written against the noOverwriteGlobs to determine whether it should be actually written to the target directory
add additional comments to relevant codes in the codebase so they are easier for future maintainers and contributors to understand.

Related issue(s)

Fixes #1128

Copy link

changeset-bot bot commented Jul 30, 2024

🦋 Changeset detected

Latest commit: 4a1f332

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@asyncapi/generator Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

lmgyuan and others added 2 commits July 30, 2024 13:48
Co-authored-by: Lukasz Gornicki <lpgornicki@gmail.com>
@lmgyuan lmgyuan requested a review from derberg July 30, 2024 18:14
@lmgyuan
Copy link
Collaborator Author

lmgyuan commented Jul 30, 2024

Updates added. Suggestions resolved.

await writeFile(testFilePath, testContent);
const fileContentBefore = await readFile(testFilePath, 'utf8');
// Check if the file was created
expect(fileContentBefore).toBe(testContent);
Copy link
Member

Choose a reason for hiding this comment

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

do we really need line 68-70? seems like we are testing here not generator code but just the FS write function 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would think so? The purpose of should ignore specified files with noOverwriteGlobs test is to make sure that the files specified by noOverwriteGlobs is not overwritten. Thus we need to check the file content after the generation.

Copy link
Member

Choose a reason for hiding this comment

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

Thus we need to check the file content after the generation.

exactly, and this is what lines 82-84 are for, where you check if content is still there after generation

in line 68-70 you basically test fs, if writeFile was successful, which I don't think is necessary

Florence-Njeri
Florence-Njeri previously approved these changes Jul 31, 2024
Copy link

sonarcloud bot commented Jul 31, 2024

@derberg
Copy link
Member

derberg commented Jul 31, 2024

/rtm

@asyncapi-bot asyncapi-bot merged commit 81dfd0c into asyncapi:master Jul 31, 2024
12 checks passed
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.

noOverwriteGlobs will not work in majority of cases in templates using react
4 participants