Skip to content

Commit

Permalink
fix: bintray configuration support for organizations
Browse files Browse the repository at this point in the history
Added a user field to BintrayOptions to use for bintray authentication instead of the 'owner' field.

Closes electron-userland#848
  • Loading branch information
jimm1419 committed Oct 25, 2016
1 parent 3eb2752 commit 7b203b5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ Array of option objects.
| --- | ---
| package | <a name="BintrayOptions-package"></a>The Bintray package name.
| repo | <a name="BintrayOptions-repo"></a>The Bintray repository name. Defaults to `generic`.
| user | <a name="BintrayOptions-user"></a>The Bintray user account. Used in cases where the owner is an organization.

<a name="GithubOptions"></a>
### `.build.publish` GitHub
Expand Down
5 changes: 5 additions & 0 deletions src/options/publishOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,9 @@ export interface BintrayOptions extends PublishConfiguration {
The Bintray repository name. Defaults to `generic`.
*/
repo?: string

/*
The Bintray user account. Used in cases where the owner is an organization.
*/
user?: string
}
2 changes: 1 addition & 1 deletion src/publish/BintrayPublisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class BintrayPublisher implements Publisher {
}
}

this.client = new BintrayClient(info.owner!, info.package!, info.repo, token)
this.client = new BintrayClient(info.owner!, info.package!, info.repo, token, info.user!)
this._versionPromise = <BluebirdPromise<Version>>this.init()
}

Expand Down
6 changes: 4 additions & 2 deletions src/publish/bintray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ export class BintrayClient {
private readonly basePath: string
readonly auth: string | null
readonly repo: string
readonly user: string

constructor(public owner: string, public packageName: string, repo?: string, apiKey?: string | null) {
constructor(public owner: string, public packageName: string, repo?: string, apiKey?: string | null, user?: string | null) {
if (owner == null) {
throw new Error("owner is not specified")
}
Expand All @@ -28,7 +29,8 @@ export class BintrayClient {
}

this.repo = repo || "generic"
this.auth = apiKey == null ? null : `Basic ${new Buffer(`${owner}:${apiKey}`).toString("base64")}`
this.user = user || owner
this.auth = apiKey == null ? null : `Basic ${new Buffer(`${this.user}:${apiKey}`).toString("base64")}`
this.basePath = `/packages/${this.owner}/${this.repo}/${this.packageName}`
}

Expand Down

0 comments on commit 7b203b5

Please sign in to comment.