fix: support tmpdir: false when the out dir is inside the project dir#1927
Open
claude[bot] wants to merge 1 commit into
Open
fix: support tmpdir: false when the out dir is inside the project dir#1927claude[bot] wants to merge 1 commit into
claude[bot] wants to merge 1 commit into
Conversation
MarshallOfSound
approved these changes
Jul 3, 2026
5 tasks
Node's fs.cp rejects copying a directory into a subdirectory of itself before the copy filter runs, so packaging with tmpdir: false and an out dir inside the project dir (e.g. Electron Forge's default ./out) failed with ERR_FS_CP_EINVAL. When the staging path is inside the app dir, copy each top-level entry individually instead, still applying the same filter so ignored paths (including the out dir itself) are skipped. Fixes #1679 Co-authored-by: ianho <anho.zhang@gmail.com>
508a875 to
fa6e95c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Samuel Attard · Slack thread
Summarize your changes:
Before: packaging with
tmpdir: falsefails withERR_FS_CP_EINVAL("cannot copy ... to a subdirectory of self") whenever theoutdir is inside the project dir — including the default./outused by Electron Forge.After: the same options package successfully, and the
outdir is still excluded from the copied app.How: with
tmpdir: falsethe staging path is the finaloutpath, socopyTemplate()'s singlefs.cp(opts.dir, resources/app)has a destination inside its source. Node'scprejects dest-inside-src up front, before the copy filter (which already ignoresoutdirs) ever runs. When the resolved destination is insideopts.dir,copyTemplate()now copies each top-level entry ofopts.dirindividually, applying the sameuserPathFilterto the top-level entries themselves — so ignored entries like theoutdir are skipped. All other cases keep the existing singlecpcall.Includes a regression test that packages with
tmpdir: falseandoutinsidedir, and asserts theoutdir is not copied intoresources/app.Fixes #1679
Supersedes #1657 — this reimplements the per-entry copy approach from that PR (credit to @ianho, who is credited as commit co-author) on top of the current
fs.promises.cp-based code.Generated by Claude Code