Skip to content

Commit

Permalink
fix: auto-unpack doesn't create file parent dirs
Browse files Browse the repository at this point in the history
Closes #689
develar committed Aug 22, 2016
1 parent bc9d437 commit 26c8360
Showing 2 changed files with 17 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/asarUtil.ts
Original file line number Diff line number Diff line change
@@ -165,12 +165,11 @@ async function detectUnpackedDirs(src: string, files: Array<string>, metadata: M
const fileParent = path.dirname(file)
if (fileParent !== nodeModuleDir && !autoUnpackDirs.has(fileParent)) {
autoUnpackDirs.add(fileParent)

createDirPromises.push(ensureDir(path.join(unpackedDest, path.relative(src, fileParent))))
if (createDirPromises.length > MAX_FILE_REQUESTS) {
await BluebirdPromise.all(createDirPromises)
createDirPromises.length = 0
}
createDirPromises.push(ensureDir(path.join(unpackedDest, path.relative(src, fileParent))))
}
continue
}
@@ -189,13 +188,21 @@ async function detectUnpackedDirs(src: string, files: Array<string>, metadata: M
}

log(`${path.relative(src, nodeModuleDir)} is not packed into asar archive - contains executable code`)
autoUnpackDirs.add(nodeModuleDir)
const fileParent = path.dirname(file)
if (fileParent !== nodeModuleDir) {

let fileParent = path.dirname(file)

// create parent dir to be able to copy file later without directory existence check
createDirPromises.push(ensureDir(path.join(unpackedDest, path.relative(src, fileParent))))
if (createDirPromises.length > MAX_FILE_REQUESTS) {
await BluebirdPromise.all(createDirPromises)
createDirPromises.length = 0
}

while (fileParent !== nodeModuleDir) {
autoUnpackDirs.add(fileParent)
// create parent dir to be able to copy file later without directory existence check
createDirPromises.push(ensureDir(path.join(unpackedDest, path.relative(src, fileParent))))
fileParent = path.dirname(fileParent)
}
autoUnpackDirs.add(nodeModuleDir)
}

if (readPackageJsonPromises.length > 0) {
3 changes: 3 additions & 0 deletions test/src/helpers/runTests.ts
Original file line number Diff line number Diff line change
@@ -161,6 +161,9 @@ function runTests(): BluebirdPromise<any> {
else if (process.platform === "win32") {
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")
}
else if (!util.isCi()) {
args.push("test/out/*.js", "!test/out/ArtifactPublisherTest.js", "!test/out/httpRequestTest.js")
}

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

0 comments on commit 26c8360

Please sign in to comment.