Skip to content

Commit 26c8360

Browse files
committed
fix: auto-unpack doesn't create file parent dirs
Closes #689
1 parent bc9d437 commit 26c8360

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

src/asarUtil.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,11 @@ async function detectUnpackedDirs(src: string, files: Array<string>, metadata: M
165165
const fileParent = path.dirname(file)
166166
if (fileParent !== nodeModuleDir && !autoUnpackDirs.has(fileParent)) {
167167
autoUnpackDirs.add(fileParent)
168-
168+
createDirPromises.push(ensureDir(path.join(unpackedDest, path.relative(src, fileParent))))
169169
if (createDirPromises.length > MAX_FILE_REQUESTS) {
170170
await BluebirdPromise.all(createDirPromises)
171171
createDirPromises.length = 0
172172
}
173-
createDirPromises.push(ensureDir(path.join(unpackedDest, path.relative(src, fileParent))))
174173
}
175174
continue
176175
}
@@ -189,13 +188,21 @@ async function detectUnpackedDirs(src: string, files: Array<string>, metadata: M
189188
}
190189

191190
log(`${path.relative(src, nodeModuleDir)} is not packed into asar archive - contains executable code`)
192-
autoUnpackDirs.add(nodeModuleDir)
193-
const fileParent = path.dirname(file)
194-
if (fileParent !== nodeModuleDir) {
191+
192+
let fileParent = path.dirname(file)
193+
194+
// create parent dir to be able to copy file later without directory existence check
195+
createDirPromises.push(ensureDir(path.join(unpackedDest, path.relative(src, fileParent))))
196+
if (createDirPromises.length > MAX_FILE_REQUESTS) {
197+
await BluebirdPromise.all(createDirPromises)
198+
createDirPromises.length = 0
199+
}
200+
201+
while (fileParent !== nodeModuleDir) {
195202
autoUnpackDirs.add(fileParent)
196-
// create parent dir to be able to copy file later without directory existence check
197-
createDirPromises.push(ensureDir(path.join(unpackedDest, path.relative(src, fileParent))))
203+
fileParent = path.dirname(fileParent)
198204
}
205+
autoUnpackDirs.add(nodeModuleDir)
199206
}
200207

201208
if (readPackageJsonPromises.length > 0) {

test/src/helpers/runTests.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ function runTests(): BluebirdPromise<any> {
161161
else if (process.platform === "win32") {
162162
args.push("test/out/*.js", "!test/out/macPackagerTest.js", "!test/out/linuxPackagerTest.js", "!test/out/CodeSignTest.js", "!test/out/ArtifactPublisherTest.js", "!test/out/httpRequestTest.js")
163163
}
164+
else if (!util.isCi()) {
165+
args.push("test/out/*.js", "!test/out/ArtifactPublisherTest.js", "!test/out/httpRequestTest.js")
166+
}
164167

165168
return utilSpawn(path.join(rootDir, "node_modules", ".bin", "ava"), args, {
166169
cwd: rootDir,

0 commit comments

Comments
 (0)