Skip to content

Commit 67ed60b

Browse files
committed
feat: option to skip installAppDependencies
Closes #442
1 parent ca120e3 commit 67ed60b

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/build-cli.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ const args = <CliOptions>(yargs
6464
.option("arch", {
6565
choices: ["ia32", "x64", "all"],
6666
})
67+
.option("npmRebuild", {
68+
describe: "Runs npm rebuild before starting to package the app.",
69+
default: true,
70+
type: "boolean",
71+
})
6772
.strict()
6873
.help()
6974
.epilog(`Project home: ${underline("https://github.com/electron-userland/electron-builder")}`)

src/packager.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,10 @@ export class Packager implements BuildInfo {
173173
}
174174

175175
private installAppDependencies(platform: Platform, arch: string): Promise<any> {
176-
if (this.isTwoPackageJsonProjectLayoutUsed) {
176+
if (!this.options.npmRebuild) {
177+
log("Skip app dependencies rebuild because npmRebuild is set to false")
178+
}
179+
else if (this.isTwoPackageJsonProjectLayoutUsed) {
177180
if (platform.nodeName === process.platform) {
178181
return installDependencies(this.appDir, this.electronVersion, arch, "rebuild")
179182
}

src/platformPackager.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ export interface PackagerOptions {
5757
* Development `package.json` will be still read, but options specified in this object will override.
5858
*/
5959
readonly devMetadata?: DevMetadata
60+
61+
readonly npmRebuild?: boolean
6062
}
6163

6264
export interface BuildInfo extends ProjectMetadataProvider {
@@ -230,8 +232,8 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
230232
}
231233

232234
protected async copyExtraFiles(appOutDir: string, arch: string, customBuildOptions: DC): Promise<any> {
233-
await this.doCopyExtraFiles(true, appOutDir, arch, this.customBuildOptions)
234-
await this.doCopyExtraFiles(false, appOutDir, arch, this.customBuildOptions)
235+
await this.doCopyExtraFiles(true, appOutDir, arch, customBuildOptions)
236+
await this.doCopyExtraFiles(false, appOutDir, arch, customBuildOptions)
235237
}
236238

237239
private async doCopyExtraFiles(isResources: boolean, appOutDir: string, arch: string, customBuildOptions: DC): Promise<Array<string>> {

0 commit comments

Comments
 (0)