Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(): do not complain on node_modules missing when beforeBuild is set #2556

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/configuration/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Env file `electron-builder.env` in the current dir ([example](https://github.com
---

* <code id="Configuration-afterSign">afterSign</code> (context: AfterPackContext) => Promise | null - The function (or path to file or module id) to be run after pack and sign (but before pack into distributable format).
* <code id="Configuration-beforeBuild">beforeBuild</code> (context: BeforeBuildContext) => Promise | null - The function (or path to file or module id) to be run before dependencies are installed or rebuilt. Works when `npmRebuild` is set to `true`. Resolving to `false` will skip dependencies install or rebuild.
* <code id="Configuration-beforeBuild">beforeBuild</code> (context: BeforeBuildContext) => Promise | null - The function (or path to file or module id) to be run before dependencies are installed or rebuilt. Works when `npmRebuild` is set to `true`. If provided and `node_modules` are missing it will not invoke production dependencies check. Resolving to `false` will skip dependencies install or rebuild.
* <code id="Configuration-remoteBuild">remoteBuild</code> = `true` Boolean - Whether to build using Electron Build Service if target not supported on current OS.
* <code id="Configuration-includePdb">includePdb</code> = `false` Boolean - Whether to include PDB files.
* <code id="Configuration-removePackageScripts">removePackageScripts</code> = `true` Boolean - Whether to remove `scripts` field from `package.json` files.
Expand Down
11 changes: 8 additions & 3 deletions packages/electron-builder-lib/src/packager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { deepAssign, addValue, Arch, archFromString, AsyncTaskManager, DebugLogg
import { CancellationToken } from "builder-util-runtime"
import { executeFinally, orNullIfFileNotExist } from "builder-util/out/promise"
import { EventEmitter } from "events"
import { ensureDir, outputFile } from "fs-extra-p"
import { ensureDir, outputFile, existsSync } from "fs-extra-p"
import isCI from "is-ci"
import { dump } from "js-yaml"
import { Lazy } from "lazy-val"
Expand Down Expand Up @@ -91,8 +91,13 @@ export class Packager {
get productionDeps(): Lazy<Array<Dependency>> {
let result = this._productionDeps
if (result == null) {
result = createLazyProductionDeps(this.appDir)
this._productionDeps = result
if (!this.config.beforeBuild || existsSync(path.join(this.appDir, "node_modules"))) {
result = createLazyProductionDeps(this.appDir)
this._productionDeps = result
} else {
// https://github.com/electron-userland/electron-builder/issues/2551
return new Lazy(() => Promise.resolve([]))
}
}
return result
}
Expand Down