Skip to content

Commit

Permalink
fix: ensure that out dir exists
Browse files Browse the repository at this point in the history
Signed-off-by: develar <develar@gmail.com>
  • Loading branch information
develar committed Feb 28, 2017
1 parent 9ac818f commit 8dd6cd5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 64 deletions.
22 changes: 20 additions & 2 deletions packages/electron-builder/src/packager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { log, warn } from "electron-builder-util/out/log"
import { all, executeFinally } from "electron-builder-util/out/promise"
import { TmpDir } from "electron-builder-util/out/tmp"
import { EventEmitter } from "events"
import { ensureDir } from "fs-extra-p"
import * as path from "path"
import { lt as isVersionLessThan } from "semver"
import { AppInfo } from "./appInfo"
Expand All @@ -16,7 +17,7 @@ import { AfterPackContext, Config, Metadata } from "./metadata"
import { ArtifactCreated, BuildInfo, PackagerOptions, SourceRepositoryInfo } from "./packagerApi"
import { PlatformPackager } from "./platformPackager"
import { getRepositoryInfo } from "./repositoryInfo"
import { createTargets } from "./targets/targetFactory"
import { createTargets, NoOpTarget } from "./targets/targetFactory"
import { doLoadConfig, getElectronVersion, loadConfig, readPackageJson, validateConfig } from "./util/readPackageJson"
import { WinPackager } from "./winPackager"
import { getGypEnv, installOrRebuild } from "./yarn"
Expand Down Expand Up @@ -195,6 +196,8 @@ export class Packager implements BuildInfo {

const platformToTarget: Map<Platform, Map<String, Target>> = new Map()

const createdOutDirs = new Set<string>()

// custom packager - don't check wine
let checkWine = this.prepackaged == null && this.options.platformPackagerFactory == null
for (const [platform, archToType] of this.options.targets!) {
Expand Down Expand Up @@ -231,7 +234,22 @@ export class Packager implements BuildInfo {
await checkWineVersion(wineCheck)
}

await helper.pack(outDir, arch, createTargets(nameToTarget, targets, outDir, helper, cleanupTasks), distTasks)
const targetList = createTargets(nameToTarget, targets, outDir, helper, cleanupTasks)
const ourDirs = new Set<string>()
for (const target of targetList) {
if (!(target instanceof NoOpTarget) && !createdOutDirs.has(target.outDir)) {
ourDirs.add(target.outDir)
}
}

if (ourDirs.size > 0) {
await BluebirdPromise.map(Array.from(ourDirs).sort(), it => {
createdOutDirs.add(it)
return ensureDir(it)
})
}

await helper.pack(outDir, arch, targetList, distTasks)
}

if (this.cancellationToken.cancelled) {
Expand Down
53 changes: 0 additions & 53 deletions test/out/__snapshots__/nsisUpdaterTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,6 @@

exports[`cancel download with progress 1`] = `"Cancelled"`;

exports[`cannot find suitable file for version 1`] = `
"Cannot find suitable file for version 1.0.0 in: [
{
\\"name\\": \\"index.js\\",
\\"path\\": \\"index.js\\",
\\"repo\\": \\"generic\\",
\\"package\\": \\"incorrect-file-version\\",
\\"version\\": \\"1.0.0\\",
\\"owner\\": \\"actperepo\\",
\\"created\\": \\"2016-08-08T06:31:26.416Z\\",
\\"size\\": 3628,
\\"sha1\\": \\"8658d188bd524e1c2372afe79bb77e9580155604\\",
\\"sha256\\": \\"b1c15917ae5f79686eedbe0767a6c4aa6a57d338c919ad9126b2141fa73a0aa8\\"
},
{
\\"name\\": \\"foo.exe\\",
\\"path\\": \\"foo.exe\\",
\\"repo\\": \\"generic\\",
\\"package\\": \\"incorrect-file-version\\",
\\"version\\": \\"1.0.0\\",
\\"owner\\": \\"actperepo\\",
\\"created\\": \\"2016-09-08T07:02:31.179Z\\",
\\"size\\": 1,
\\"sha1\\": \\"adc83b19e793491b1c6ea0fd8b46cd9f32e592fc\\",
\\"sha256\\": \\"01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b\\"
},
{
\\"name\\": \\"11TestApp Setup 1.1.0.exe\\",
\\"path\\": \\"11TestApp Setup 1.1.0.exe\\",
\\"repo\\": \\"generic\\",
\\"package\\": \\"incorrect-file-version\\",
\\"version\\": \\"1.0.0\\",
\\"owner\\": \\"actperepo\\",
\\"created\\": \\"2016-09-18T16:51:26.240Z\\",
\\"size\\": 1,
\\"sha1\\": \\"adc83b19e793491b1c6ea0fd8b46cd9f32e592fc\\",
\\"sha256\\": \\"01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b\\"
},
{
\\"name\\": \\"11TestApp Setup 1.1.0 copy.exe\\",
\\"path\\": \\"11TestApp Setup 1.1.0 copy.exe\\",
\\"repo\\": \\"generic\\",
\\"package\\": \\"incorrect-file-version\\",
\\"version\\": \\"1.0.0\\",
\\"owner\\": \\"actperepo\\",
\\"created\\": \\"2016-09-18T16:51:26.095Z\\",
\\"size\\": 1,
\\"sha1\\": \\"adc83b19e793491b1c6ea0fd8b46cd9f32e592fc\\",
\\"sha256\\": \\"01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b\\"
}
]"
`;

exports[`check updates - no versions at all 1`] = `"No latest version, please ensure that user, package and repository correctly configured. Or at least one version is published. HttpError: 404 Not Found"`;

exports[`checkForUpdates several times 1`] = `
Expand Down
18 changes: 9 additions & 9 deletions test/src/nsisUpdaterTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ test("check updates - no versions at all", async () => {
await assertThat(updater.checkForUpdates()).throws()
})

test("cannot find suitable file for version", async () => {
const updater = new NsisUpdater(<BintrayOptions>{
provider: "bintray",
owner: "actperepo",
package: "incorrect-file-version",
})

await assertThat(updater.checkForUpdates()).throws()
})
// test("cannot find suitable file for version", async () => {
// const updater = new NsisUpdater(<BintrayOptions>{
// provider: "bintray",
// owner: "actperepo",
// package: "incorrect-file-version",
// })
//
// await assertThat(updater.checkForUpdates()).throws()
// })

test("file url", async () => {
const updater = new NsisUpdater()
Expand Down

0 comments on commit 8dd6cd5

Please sign in to comment.