Skip to content

Commit

Permalink
fix: allow packaging twice simultaneously (#1439)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshallOfSound committed Nov 1, 2022
1 parent c772bff commit 745d286
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
12 changes: 7 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class Packager {
}

async testSymlink (comboOpts, zipPath) {
const testPath = path.join(this.tempBase, `symlink-test-${comboOpts.platform}-${comboOpts.arch}`)
await fs.mkdirp(this.tempBase)
const testPath = await fs.mkdtemp(path.join(this.tempBase, `symlink-test-${comboOpts.platform}-${comboOpts.arch}-`))
const testFile = path.join(testPath, 'test')
const testLink = path.join(testPath, 'testlink')

Expand Down Expand Up @@ -74,18 +75,19 @@ class Packager {
await hooks.promisifyHooks(this.opts.afterExtract, [buildDir, comboOpts.electronVersion, comboOpts.platform, comboOpts.arch])
}

buildDir (platform, arch) {
async buildDir (platform, arch) {
let buildParentDir
if (this.useTempDir) {
buildParentDir = this.tempBase
} else {
buildParentDir = this.opts.out || process.cwd()
}
return path.resolve(buildParentDir, `${platform}-${arch}-template`)
await fs.mkdirp(buildParentDir)
return await fs.mkdtemp(path.resolve(buildParentDir, `${platform}-${arch}-template-`))
}

async createApp (comboOpts, zipPath) {
const buildDir = this.buildDir(comboOpts.platform, comboOpts.arch)
const buildDir = await this.buildDir(comboOpts.platform, comboOpts.arch)
common.info(`Packaging app for platform ${comboOpts.platform} ${comboOpts.arch} using electron v${comboOpts.electronVersion}`, this.opts.quiet)

debug(`Creating ${buildDir}`)
Expand Down Expand Up @@ -159,7 +161,7 @@ class Packager {
}

if (common.isPlatformMac(comboOpts.platform) && comboOpts.arch === 'universal') {
return packageUniversalMac(this.packageForPlatformAndArchWithOpts.bind(this), this.buildDir(comboOpts.platform, comboOpts.arch), comboOpts, downloadOpts, this.tempBase)
return packageUniversalMac(this.packageForPlatformAndArchWithOpts.bind(this), await this.buildDir(comboOpts.platform, comboOpts.arch), comboOpts, downloadOpts, this.tempBase)
}

return this.packageForPlatformAndArchWithOpts(comboOpts, downloadOpts)
Expand Down
14 changes: 9 additions & 5 deletions src/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,15 @@ class App {
if (this.opts.tmpdir === false) {
return common.generateFinalPath(this.opts)
} else {
return path.join(
common.baseTempDir(this.opts),
`${this.opts.platform}-${this.opts.arch}`,
common.generateFinalBasename(this.opts)
)
if (!this.cachedStagingPath) {
const parentDir = path.join(
common.baseTempDir(this.opts),
`${this.opts.platform}-${this.opts.arch}`
)
fs.mkdirpSync(parentDir)
this.cachedStagingPath = fs.mkdtempSync(path.join(parentDir, `${common.generateFinalBasename(this.opts)}-`))
}
return this.cachedStagingPath
}
}

Expand Down

0 comments on commit 745d286

Please sign in to comment.