diff --git a/.idea/dictionaries/develar.xml b/.idea/dictionaries/develar.xml
index 5e2a7ff90fa..f7a5359c01c 100644
--- a/.idea/dictionaries/develar.xml
+++ b/.idea/dictionaries/develar.xml
@@ -31,6 +31,7 @@
chown
circleci
clcerts
+ cleanuped
cleanuper
codesigning
controlfields
diff --git a/packages/electron-builder/src/asarUtil.ts b/packages/electron-builder/src/asarUtil.ts
index d3b0c081362..8c15f509f7b 100644
--- a/packages/electron-builder/src/asarUtil.ts
+++ b/packages/electron-builder/src/asarUtil.ts
@@ -190,10 +190,22 @@ class AsarPackager {
const fileParent = path.dirname(file)
const dirNode = this.fs.searchNodeFromPath(fileParent)
const packageDataPromise = fileIndexToModulePackageData.get(i)
- let newData: any | null = null
+ let newData: string | null = null
if (packageDataPromise == null) {
- if (this.options.extraMetadata != null && file === mainPackageJson) {
- newData = JSON.stringify(deepAssign(await readJson(file), this.options.extraMetadata), null, 2)
+ if (file === mainPackageJson) {
+ const mainPackageData = await readJson(file)
+ if (this.options.extraMetadata != null) {
+ deepAssign(mainPackageData, this.options.extraMetadata)
+ }
+
+ // https://github.com/electron-userland/electron-builder/issues/1212
+ const serializedDataIfChanged = cleanupPackageJson(mainPackageData)
+ if (serializedDataIfChanged != null) {
+ newData = serializedDataIfChanged
+ }
+ else if (this.options.extraMetadata != null) {
+ newData = JSON.stringify(mainPackageData, null, 2)
+ }
}
}
else {
@@ -352,7 +364,7 @@ function cleanupPackageJson(data: any): any {
try {
let changed = false
for (const prop of Object.getOwnPropertyNames(data)) {
- if (prop[0] === "_" || prop === "dist" || prop === "gitHead" || prop === "keywords") {
+ if (prop[0] === "_" || prop === "dist" || prop === "gitHead" || prop === "keywords" || prop === "build" || prop === "devDependencies" || prop === "scripts") {
delete data[prop]
changed = true
}
diff --git a/packages/electron-builder/src/platformPackager.ts b/packages/electron-builder/src/platformPackager.ts
index 438920371b9..23e96904296 100644
--- a/packages/electron-builder/src/platformPackager.ts
+++ b/packages/electron-builder/src/platformPackager.ts
@@ -128,7 +128,11 @@ export abstract class PlatformPackager
log(`Packaging for ${platformName} ${Arch[arch]} using electron ${this.info.electronVersion} to ${path.relative(this.projectDir, appOutDir)}`)
const appDir = this.info.appDir
- const ignoreFiles = new Set([path.resolve(this.info.projectDir, outDir), path.resolve(this.info.projectDir, this.buildResourcesDir)])
+ const ignoreFiles = new Set([path.resolve(this.info.projectDir, outDir),
+ path.resolve(this.info.projectDir, this.buildResourcesDir),
+ path.resolve(this.info.projectDir, "electron-builder.yml"),
+ path.resolve(this.info.projectDir, "electron-builder.json"),
+ path.resolve(this.info.projectDir, "electron-builder.json5")])
if (this.info.isPrepackedAppAsar) {
await unpackElectron(this, appOutDir, platformName, Arch[arch], this.info.electronVersion)
}
diff --git a/test/out/__snapshots__/extraMetadataTest.js.snap b/test/out/__snapshots__/extraMetadataTest.js.snap
index 05841269787..f7972aa26b8 100644
--- a/test/out/__snapshots__/extraMetadataTest.js.snap
+++ b/test/out/__snapshots__/extraMetadataTest.js.snap
@@ -1,20 +1,6 @@
exports[`test extra metadata 1`] = `
Object {
"author": "Foo Bar ",
- "build": Object {
- "appId": "org.electron-builder.testApp",
- "compression": "store",
- "electronVersion": "1.4.12",
- "iconUrl": "https://raw.githubusercontent.com/szwacz/electron-boilerplate/master/resources/windows/icon.ico",
- "linux": Object {
- "category": "Development",
- "packageCategory": "devel",
- },
- "mac": Object {
- "category": "your.app.category.type",
- },
- "npmRebuild": false,
- },
"description": "Test Application (test quite \" #378)",
"foo": Object {
"bar": 12,
diff --git a/test/out/__snapshots__/globTest.js.snap b/test/out/__snapshots__/globTest.js.snap
index 4e683aaf138..146b061bbac 100644
--- a/test/out/__snapshots__/globTest.js.snap
+++ b/test/out/__snapshots__/globTest.js.snap
@@ -6,7 +6,7 @@ Object {
exports[`test outside link 1`] = `
Object {
- "offset": "5290",
+ "offset": "4877",
"size": 4,
}
`;
diff --git a/test/src/extraMetadataTest.ts b/test/src/extraMetadataTest.ts
index 4a38a64ceec..bf308ac892b 100644
--- a/test/src/extraMetadataTest.ts
+++ b/test/src/extraMetadataTest.ts
@@ -18,6 +18,8 @@ test.ifDevOrLinuxCi("extra metadata", app({
},
}, {
projectDirCreated: projectDir => modifyPackageJson(projectDir, data => {
+ data.scripts = {}
+ data.devDependencies = {"foo": "boo"}
data.foo = {
bar: 42,
existingProp: 22,
diff --git a/test/src/linux/linuxPackagerTest.ts b/test/src/linux/linuxPackagerTest.ts
index 857076f44f8..a9e59d58a00 100755
--- a/test/src/linux/linuxPackagerTest.ts
+++ b/test/src/linux/linuxPackagerTest.ts
@@ -3,6 +3,7 @@ import { remove, readFile, rename } from "fs-extra-p"
import * as path from "path"
import { Platform, build } from "electron-builder"
import { assertThat } from "../helpers/fileAssert"
+import { ELECTRON_VERSION } from "../helpers/config"
test.ifDevOrLinuxCi("AppImage", app({targets: Platform.LINUX.createTarget()}))
@@ -38,6 +39,10 @@ test.ifNotWindows("icons from ICNS", app({targets: Platform.LINUX.createTarget()
await build({
targets: Platform.LINUX.createTarget(),
projectDir: projectDir,
+ config: {
+ electronVersion: ELECTRON_VERSION,
+ compression: "store",
+ }
})
await assertThat(path.join(projectDir, "dist")).isDirectory()