diff --git a/src/index.js b/src/index.js index d4e04110..d64afd46 100644 --- a/src/index.js +++ b/src/index.js @@ -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') @@ -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}`) @@ -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) diff --git a/src/platform.js b/src/platform.js index 1ed1c683..adec6b04 100644 --- a/src/platform.js +++ b/src/platform.js @@ -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 } }