Skip to content

Commit 687ad33

Browse files
authored
fix: error when commonDistDirectory changed to custom value (#351)
1 parent e46f37c commit 687ad33

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

packages/electron-webpack/src/dev/dev-runner.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,17 @@ let socketPath: string | null = null
1818

1919
const debug = require("debug")("electron-webpack")
2020

21-
// do not remove main.js to allow IDE to keep breakpoints
22-
async function emptyMainOutput() {
21+
async function getOutDir() {
2322
const electronWebpackConfig = await getElectronWebpackConfiguration({
2423
projectDir,
2524
packageMetadata: getPackageMetadata(projectDir),
2625
})
27-
const outDir = path.join(electronWebpackConfig.commonDistDirectory!!, "main")
26+
return path.join(electronWebpackConfig.commonDistDirectory!!, "main")
27+
}
28+
29+
// do not remove main.js to allow IDE to keep breakpoints
30+
async function emptyMainOutput() {
31+
const outDir = await getOutDir()
2832
const files = await orNullIfFileNotExist(readdir(outDir))
2933
if (files == null) {
3034
return
@@ -59,8 +63,9 @@ class DevRunner {
5963
})
6064

6165
const electronArgs = process.env.ELECTRON_ARGS
66+
const outDir = await getOutDir()
6267
const args = electronArgs != null && electronArgs.length > 0 ? JSON.parse(electronArgs) : [`--inspect=${await getFreePort("127.0.0.1", 5858)}`]
63-
args.push(path.join(projectDir, "dist/main/main.js"))
68+
args.push(path.join(outDir, "/main.js"))
6469
// Pass remaining arguments to the application. Remove 3 instead of 2, to remove the `dev` argument as well.
6570
args.push(...process.argv.slice(3))
6671
// we should start only when both start and main are started

0 commit comments

Comments
 (0)