diff --git a/.changeset/witty-countries-heal.md b/.changeset/witty-countries-heal.md new file mode 100644 index 00000000000..3a9a9c9b554 --- /dev/null +++ b/.changeset/witty-countries-heal.md @@ -0,0 +1,5 @@ +--- +"app-builder-lib": patch +--- + +fix: don't unpack root dir of unpacked path hierarchy diff --git a/packages/app-builder-lib/src/asar/asarUtil.ts b/packages/app-builder-lib/src/asar/asarUtil.ts index fcdca3ac8a7..7d911a600a4 100644 --- a/packages/app-builder-lib/src/asar/asarUtil.ts +++ b/packages/app-builder-lib/src/asar/asarUtil.ts @@ -1,4 +1,4 @@ -import { createPackageFromStreams, AsarStreamType, AsarDirectory } from "@electron/asar" +import { createPackageFromStreams, AsarStreamType } from "@electron/asar" import { log } from "builder-util" import { Filter } from "builder-util/out/fs" import * as fs from "fs-extra" @@ -78,8 +78,6 @@ export class AsarPackager { return isChild || isFileUnpacked } - this.processParentDirectories(isUnpacked, destination, results) - const result = await this.processFileOrSymlink({ file, destination, @@ -96,24 +94,6 @@ export class AsarPackager { return results } - private processParentDirectories(isUnpacked: (path: string) => boolean, destination: string, results: AsarStreamType[]) { - // process parent directories - let superDir = path.dirname(path.normalize(destination)) - while (superDir !== ".") { - const dir: AsarDirectory = { - type: "directory", - path: superDir, - unpacked: isUnpacked(superDir), - } - // add to results if not already present - if (!results.some(r => r.path === dir.path)) { - results.push(dir) - } - - superDir = path.dirname(superDir) - } - } - private async processFileOrSymlink(options: { file: string destination: string diff --git a/test/snapshots/BuildTest.js.snap b/test/snapshots/BuildTest.js.snap index 1786c4092f3..40dab8609b9 100644 --- a/test/snapshots/BuildTest.js.snap +++ b/test/snapshots/BuildTest.js.snap @@ -1065,10 +1065,8 @@ exports[`posix smart unpack 3`] = ` "unpacked": true, }, }, - "unpacked": true, }, }, - "unpacked": true, }, "lib": { "files": { @@ -1077,14 +1075,12 @@ exports[`posix smart unpack 3`] = ` "unpacked": true, }, }, - "unpacked": true, }, "package.json": { "size": "", "unpacked": true, }, }, - "unpacked": true, }, "mimic-response": { "files": { @@ -5149,7 +5145,6 @@ exports[`smart unpack local module with dll file 2`] = ` "unpacked": true, }, }, - "unpacked": true, }, "edge-cs.dll": { "size": "", @@ -5160,7 +5155,6 @@ exports[`smart unpack local module with dll file 2`] = ` "unpacked": true, }, }, - "unpacked": true, }, "package.json": { "size": "", @@ -5187,7 +5181,6 @@ exports[`smart unpack local module with dll file 2`] = ` "unpacked": true, }, }, - "unpacked": true, }, "edge-cs": { "files": { @@ -5202,13 +5195,10 @@ exports[`smart unpack local module with dll file 2`] = ` "unpacked": true, }, }, - "unpacked": true, }, }, - "unpacked": true, }, }, - "unpacked": true, }, "tools": { "files": { @@ -5217,10 +5207,8 @@ exports[`smart unpack local module with dll file 2`] = ` "unpacked": true, }, }, - "unpacked": true, }, }, - "unpacked": true, }, "foo": { "files": { @@ -5233,7 +5221,6 @@ exports[`smart unpack local module with dll file 2`] = ` "unpacked": true, }, }, - "unpacked": true, }, "ms": { "files": { @@ -5360,7 +5347,6 @@ exports[`win smart unpack 2`] = ` "unpacked": true, }, }, - "unpacked": true, }, "test-smart-unpack-empty": { "files": { @@ -5422,7 +5408,6 @@ exports[`win smart unpack 2`] = ` "unpacked": true, }, }, - "unpacked": true, }, "edge-cs.dll": { "size": "", @@ -5433,7 +5418,6 @@ exports[`win smart unpack 2`] = ` "unpacked": true, }, }, - "unpacked": true, }, "package.json": { "size": "", @@ -5460,7 +5444,6 @@ exports[`win smart unpack 2`] = ` "unpacked": true, }, }, - "unpacked": true, }, "edge-cs": { "files": { @@ -5475,13 +5458,10 @@ exports[`win smart unpack 2`] = ` "unpacked": true, }, }, - "unpacked": true, }, }, - "unpacked": true, }, }, - "unpacked": true, }, "tools": { "files": { @@ -5490,10 +5470,8 @@ exports[`win smart unpack 2`] = ` "unpacked": true, }, }, - "unpacked": true, }, }, - "unpacked": true, }, "ms": { "files": { diff --git a/test/snapshots/globTest.js.snap b/test/snapshots/globTest.js.snap index ddb0a54b011..d50a111b7ba 100644 --- a/test/snapshots/globTest.js.snap +++ b/test/snapshots/globTest.js.snap @@ -61,10 +61,8 @@ exports[`isInstallDepsBefore=true > asarUnpack node_modules 2`] = ` "unpacked": true, }, }, - "unpacked": true, }, }, - "unpacked": true, } `; @@ -9883,7 +9881,6 @@ exports[`isInstallDepsBefore=true > symlinks everywhere with static framework 3` "unpacked": true, }, }, - "unpacked": true, }, "Hello": { "size": "", @@ -9930,7 +9927,6 @@ exports[`isInstallDepsBefore=true > symlinks everywhere with static framework 3` "unpacked": true, }, }, - "unpacked": true, }, "Hello.swiftsourceinfo": { "size": "", @@ -9941,33 +9937,26 @@ exports[`isInstallDepsBefore=true > symlinks everywhere with static framework 3` "unpacked": true, }, }, - "unpacked": true, }, }, - "unpacked": true, }, "Current": { "link": "node_modules/hello-world/lib/Release/Hello.framework/Versions/A", "unpacked": true, }, }, - "unpacked": true, }, }, - "unpacked": true, }, }, - "unpacked": true, }, }, - "unpacked": true, }, "package.json": { "size": "", "unpacked": true, }, }, - "unpacked": true, }, "ms": { "files": { @@ -10111,10 +10100,8 @@ exports[`unpackDir 2`] = ` "unpacked": true, }, }, - "unpacked": true, }, }, - "unpacked": true, }, "b2": { "files": { @@ -10123,7 +10110,6 @@ exports[`unpackDir 2`] = ` "unpacked": true, }, }, - "unpacked": true, }, "do-not-unpack-dir": { "files": { @@ -10230,10 +10216,8 @@ exports[`unpackDir one 2`] = ` "unpacked": true, }, }, - "unpacked": true, }, }, - "unpacked": true, }, "b2": { "files": { @@ -10242,7 +10226,6 @@ exports[`unpackDir one 2`] = ` "unpacked": true, }, }, - "unpacked": true, }, "do-not-unpack-dir": { "files": {