Skip to content

Commit

Permalink
fix: Cannot find module 'electron-download-tf'
Browse files Browse the repository at this point in the history
Close #2550
  • Loading branch information
develar committed Feb 6, 2018
1 parent 22ee3e9 commit c57c52a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
16 changes: 2 additions & 14 deletions packages/electron-builder-lib/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { CancellationToken } from "builder-util-runtime"
import { executeFinally } from "builder-util/out/promise"
import { PublishOptions } from "electron-publish/out/publisher"
import { log } from "builder-util"
import { Packager } from "./packager"
import { PackagerOptions } from "./packagerApi"
import BluebirdPromise from "bluebird-lst"
import { PublishManager } from "./publish/PublishManager"

export { Packager, BuildResult } from "./packager"
Expand Down Expand Up @@ -32,17 +30,7 @@ export { PublishManager } from "./publish/PublishManager"
export { PlatformPackager } from "./platformPackager"
export { buildForge, ForgeOptions } from "./forge-maker"

export async function build(options: PackagerOptions & PublishOptions, cancellationToken: CancellationToken = new CancellationToken()): Promise<Array<string>> {
const packager = new Packager(options, cancellationToken)

let electronDownloader: any = null
packager.electronDownloader = options => {
if (electronDownloader == null) {
electronDownloader = BluebirdPromise.promisify(require("electron-download-tf"))
}
return electronDownloader(options)
}

export async function build(options: PackagerOptions & PublishOptions, packager: Packager = new Packager(options)): Promise<Array<string>> {
// because artifact event maybe dispatched several times for different publish providers
const artifactPaths = new Set<string>()
packager.artifactCreated(event => {
Expand All @@ -54,7 +42,7 @@ export async function build(options: PackagerOptions & PublishOptions, cancellat
const publishManager = new PublishManager(packager, options)
const sigIntHandler = () => {
log.warn("cancelled by SIGINT")
cancellationToken.cancel()
packager.cancellationToken.cancel()
publishManager.cancelTasks()
}
process.once("SIGINT", sigIntHandler)
Expand Down
15 changes: 13 additions & 2 deletions packages/electron-builder/src/builder.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { addValue, Arch, archFromString, InvalidConfigurationError, log, deepAssign } from "builder-util"
import chalk from "chalk"
import { build as _build, Configuration, DIR_TARGET, PackagerOptions, Platform } from "electron-builder-lib"
import { Packager, build as _build, Configuration, DIR_TARGET, PackagerOptions, Platform } from "electron-builder-lib"
import { PublishOptions } from "electron-publish"
import BluebirdPromise from "bluebird-lst"

/** @internal */
export interface BuildOptions extends PackagerOptions, PublishOptions {
Expand Down Expand Up @@ -214,7 +215,17 @@ export function createTargets(platforms: Array<Platform>, type?: string | null,
}

export function build(rawOptions?: CliOptions): Promise<Array<string>> {
return _build(normalizeOptions(rawOptions || {}))
const buildOptions = normalizeOptions(rawOptions || {})
const packager = new Packager(buildOptions)

let electronDownloader: any = null
packager.electronDownloader = options => {
if (electronDownloader == null) {
electronDownloader = BluebirdPromise.promisify(require("electron-download-tf"))
}
return electronDownloader(options)
}
return _build(buildOptions, packager)
}

/**
Expand Down
4 changes: 2 additions & 2 deletions test/src/helpers/checkDeps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ async function check(projectDir: string, devPackageData: any): Promise<boolean>
}

for (const name of Object.keys(result.missing)) {
if (name === "electron-builder-squirrel-windows" || name === "electron-webpack" || name === "electron-download-tf" ||
(packageName === "electron-builder-lib" && name === "dmg-builder")) {
if (name === "electron-builder-squirrel-windows" || name === "electron-webpack" ||
(packageName === "electron-builder-lib" && (name === "dmg-builder" || name === "electron-download-tf"))) {
delete (result.missing as any)[name]
}
}
Expand Down

0 comments on commit c57c52a

Please sign in to comment.