From 5d64693632469cbd4418d905703bd2dda56a68a8 Mon Sep 17 00:00:00 2001 From: develar <develar@gmail.com> Date: Sat, 28 Jan 2017 21:46:55 +0100 Subject: [PATCH] fix(deployment): warn "A release is already published" instead of error Close #1183 --- .../electron-builder/src/publish/PublishManager.ts | 6 +++--- .../electron-builder/src/publish/gitHubPublisher.ts | 13 ++++--------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/packages/electron-builder/src/publish/PublishManager.ts b/packages/electron-builder/src/publish/PublishManager.ts index ed8bd39fd88..c8484820028 100644 --- a/packages/electron-builder/src/publish/PublishManager.ts +++ b/packages/electron-builder/src/publish/PublishManager.ts @@ -115,7 +115,7 @@ export class PublishManager { getOrCreatePublisher(publishConfig: PublishConfiguration, buildInfo: BuildInfo): Publisher | null { let publisher = this.nameToPublisher.get(publishConfig.provider) if (publisher == null) { - publisher = createPublisher(buildInfo, publishConfig, this.publishOptions, this.isPublishOptionGuessed) + publisher = createPublisher(buildInfo, publishConfig, this.publishOptions) this.nameToPublisher.set(publishConfig.provider, publisher) } return publisher @@ -242,12 +242,12 @@ async function writeUpdateInfo(event: ArtifactCreated, _publishConfigs: Array<Pu } } -function createPublisher(buildInfo: BuildInfo, publishConfig: PublishConfiguration, options: PublishOptions, isPublishOptionGuessed: boolean = false): Publisher | null { +function createPublisher(buildInfo: BuildInfo, publishConfig: PublishConfiguration, options: PublishOptions): Publisher | null { const version = buildInfo.metadata.version! if (publishConfig.provider === "github") { const githubInfo: GithubOptions = publishConfig log(`Creating Github Publisher — owner: ${githubInfo.owner}, project: ${githubInfo.repo}, version: ${version}`) - return new GitHubPublisher(githubInfo, version, options, isPublishOptionGuessed) + return new GitHubPublisher(githubInfo, version, options) } if (publishConfig.provider === "bintray") { const bintrayInfo: BintrayOptions = publishConfig diff --git a/packages/electron-builder/src/publish/gitHubPublisher.ts b/packages/electron-builder/src/publish/gitHubPublisher.ts index 6fe998549ae..9390183ba32 100644 --- a/packages/electron-builder/src/publish/gitHubPublisher.ts +++ b/packages/electron-builder/src/publish/gitHubPublisher.ts @@ -41,7 +41,7 @@ export class GitHubPublisher extends Publisher { return this._releasePromise } - constructor(private readonly info: GithubOptions, private readonly version: string, private readonly options: PublishOptions = {}, private readonly isPublishOptionGuessed: boolean = false) { + constructor(private readonly info: GithubOptions, private readonly version: string, private readonly options: PublishOptions = {}) { super() let token = info.token @@ -74,14 +74,9 @@ export class GitHubPublisher extends Publisher { // if release created < 2 hours — allow to upload const publishedAt = release.published_at == null ? null : new Date(release.published_at) if (publishedAt != null && (Date.now() - publishedAt.getMilliseconds()) > (2 * 3600 * 1000)) { - const message = `Release with tag ${this.tag} published at ${publishedAt.toString()}, more than 2 hours ago` - if (this.isPublishOptionGuessed) { - warn(message) - return null - } - else { - throw new Error(message) - } + // https://github.com/electron-userland/electron-builder/issues/1183#issuecomment-275867187 + warn(`Release with tag ${this.tag} published at ${publishedAt.toString()}, more than 2 hours ago`) + return null } return release }