Skip to content

Commit

Permalink
feat: Ability to set author/CompanyName programmatically
Browse files Browse the repository at this point in the history
Closes #455
  • Loading branch information
develar committed Jun 11, 2016
1 parent e5b0c04 commit 63c2529
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/packager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class Packager implements BuildInfo {
this.isTwoPackageJsonProjectLayoutUsed = this.appDir !== this.projectDir

const appPackageFile = this.projectDir === this.appDir ? devPackageFile : path.join(this.appDir, "package.json")
this.metadata = appPackageFile === devPackageFile ? this.devMetadata : await readPackageJson(appPackageFile)
this.metadata = appPackageFile === devPackageFile ? (this.options.appMetadata || this.devMetadata) : deepAssign(await readPackageJson(appPackageFile), this.options.appMetadata)

this.checkMetadata(appPackageFile, devPackageFile)
checkConflictingOptions(this.devMetadata.build)
Expand Down
7 changes: 7 additions & 0 deletions src/platformPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ export interface PackagerOptions {
* Development `package.json` will be still read, but options specified in this object will override.
*/
readonly devMetadata?: DevMetadata

/**
* The same as [application package.json](https://github.com/electron-userland/electron-builder/wiki/Options#AppMetadata).
*
* Application `package.json` will be still read, but options specified in this object will override.
*/
readonly appMetadata?: DevMetadata
}

export interface BuildInfo extends ProjectMetadataProvider {
Expand Down
2 changes: 1 addition & 1 deletion test/src/ArtifactPublisherTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ testAndIgnoreApiRate("prerelease", async () => {
const r = await publisher.getRelease()
assertThat(r).has.properties({
prerelease: true,
draft: true,
draft: false,
})
}
finally {
Expand Down
5 changes: 3 additions & 2 deletions test/src/BuildTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ test("name in the build", t => t.throws(assertPack("test-app-one", currentPlatfo
})
}), /'name' in the 'build' is forbidden/))

test("empty description", t => t.throws(assertPack("test-app-one", {
// this test also test appMetadata, so, we must use test-app here
test("empty description", t => t.throws(assertPack("test-app", {
targets: Platform.LINUX.createTarget(),
devMetadata: <any>{
appMetadata: <any>{
description: "",
}
}), /Please specify 'description'/))
Expand Down

0 comments on commit 63c2529

Please sign in to comment.