Skip to content

Commit da1d768

Browse files
authored
fix: only use hardlinks during unit tests (or explicitly override) to avoid breaking debian builds where /opt is on a different drive (#9397)
1 parent 8138e27 commit da1d768

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

.changeset/odd-worms-shop.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"builder-util": patch
3+
---
4+
5+
fix: only use hardlinks during unit tests to avoid breaking debian builds where /opt is on a different drive

packages/builder-util/src/fs.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { Nullish } from "builder-util-runtime"
22
import { Stats } from "fs"
33
import { copyFile as _nodeCopyFile } from "fs-extra"
44
import { access, chmod, link, lstat, mkdir, readdir, readlink, stat, symlink, unlink, writeFile } from "fs/promises"
5-
import { isCI } from "ci-info"
65
import { platform } from "os"
76
import * as path from "path"
87
import { Mode } from "stat-mode"
@@ -149,7 +148,10 @@ export async function walk(initialDirPath: string, filter?: Filter | null, consu
149148
return result
150149
}
151150

152-
const _isUseHardLink = process.platform !== "win32" && process.env.USE_HARD_LINKS !== "false" && (isCI || process.env.USE_HARD_LINKS === "true")
151+
// performance optimization. only enable hard links during unit tests on non-Windows platforms by default
152+
// This is to optimize disk space and speed during tests, while avoiding potential issues with hard links in distribution builds
153+
// https://github.com/electron-userland/electron-builder/issues/5721
154+
const _isUseHardLink = process.platform !== "win32" && (process.env.USE_HARD_LINKS === "true" || process.env.VITEST != null)
153155

154156
export function copyFile(src: string, dest: string, isEnsureDir = true) {
155157
return (isEnsureDir ? mkdir(path.dirname(dest), { recursive: true }) : Promise.resolve()).then(() => copyOrLinkFile(src, dest, null, false))

0 commit comments

Comments
 (0)