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: copyTemplate failed if tmpdir set to false #1657

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ianho
Copy link

@ianho ianho commented Jan 10, 2024

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project follows, as appropriate.
  • The changes are appropriately documented (if applicable).
  • The changes have sufficient test coverage (if applicable).
  • The testsuite passes successfully on my local machine (if applicable).

Summarize your changes:

if tmpdir set to false, fs-extra copy api will throw a error that Cannot copy 'xxx' to a subdirectory of itself, 'xxx/out/xxx'.

so we cant call fs.copy in this case, traverse first-level directories to call fs.copy instead

@ianho ianho requested a review from a team as a code owner January 10, 2024 06:39
Copy link

codecov bot commented Jan 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (aa6fd4c) 92.03% compared to head (513e087) 91.90%.
Report is 18 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1657      +/-   ##
==========================================
- Coverage   92.03%   91.90%   -0.13%     
==========================================
  Files          16       16              
  Lines         854      865      +11     
  Branches      167      171       +4     
==========================================
+ Hits          786      795       +9     
- Misses         51       52       +1     
- Partials       17       18       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@BlackHole1 BlackHole1 left a comment

Choose a reason for hiding this comment

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

Thank you for your PR!
It would be better if you could explain in detail in the PR why this issue occurred. From the existing PR description and code changes, it is difficult for me to understand the reason behind them. I only understood the reason after reviewing the source code of fs.copy (because the condition is checked before the filter).

if (!include) return;

return fs.copy(srcItem, destItem, {
filter,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
filter,

Since the judgment has already been made before, there is no need to let fs.copy execute the judgment again.

@BlackHole1
Copy link
Member

PTAL @malept @erikian

filter: userPathFilter(this.opts),
dereference: this.opts.derefSymlinks,
});
if (this.opts.tmpdir === false) {
Copy link
Member

Choose a reason for hiding this comment

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

Hey @ianho, we discussed this in an Ecosystem WG meeting and I think this PR is the best solution for https://github.com/electron/forge/issues/3475 as well since it resolves the problem upstream.

Two blockers here:

  • Can we add a comment explaining why this is necessary about line 156?
  • We should add a test for this code so it doesn't regress in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants