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

fix: when generating app with no 'test'/'src' folder to move #1493

Merged
merged 2 commits into from
Jul 31, 2023
Merged

fix: when generating app with no 'test'/'src' folder to move #1493

merged 2 commits into from
Jul 31, 2023

Conversation

micalevisk
Copy link
Member

@micalevisk micalevisk commented Jul 23, 2023

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Issue Number: closes #1492

given this project:

image

(note that we have the 'test' folder just to see what's the happy path)

running npx nest g app qux will perform the following operations:

image

we are deleting every file within the directories that will be moved ('src' and 'test')

What is the new behavior?

now that same command will do this instead:

image

  • only 2 delete operations, one for each folder being deleted
  • ignore if the folder does not exists

when there is no 'test' folder in the project, we'd see:

image

image

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@@ -279,9 +279,8 @@ function moveDirectoryTo(
tree.getDir(srcDir).visit((filePath: Path, file: Readonly<FileEntry>) => {
const newFilePath = join(destination as Path, filePath);
tree.create(newFilePath, file.content);
tree.delete(filePath);
tree.delete(srcDir);
Copy link
Member

Choose a reason for hiding this comment

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

Even though it may fix the reported issue, are we sure that calling tree.delete(srcDir); X times makes sense?

Copy link
Member Author

Choose a reason for hiding this comment

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

indeed

although we're calling tree.delete several times, looks like angular schematics is treating such usage:

image

I'm still trying another way to achieve that. tree.exists didn't worked, just the usual try-catch on tree.delete

@micalevisk micalevisk changed the title fix: when generating app with no 'test'/'src' folder to copy fix: when generating app with no 'test'/'src' folder to move Jul 30, 2023
@kamilmysliwiec kamilmysliwiec merged commit 9a7bcfe into nestjs:master Jul 31, 2023
1 check passed
@kamilmysliwiec kamilmysliwiec added the bug Something isn't working label Jul 31, 2023
@kamilmysliwiec
Copy link
Member

LGTM

@micalevisk micalevisk deleted the patch-1 branch July 31, 2023 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error when using 'application' generator in a directory that doesn't has the 'test' folder
2 participants