Skip to content

The agent that grows with you

fix(desktop): widen libuv-only staging to get-windows and the rollback .bak wipe

teknium1afb9243f9ce4
diff --git a/apps/desktop/scripts/before-pack.mjs b/apps/desktop/scripts/before-pack.mjs
index c95853bd879..cb8ce15d617 100644
--- a/apps/desktop/scripts/before-pack.mjs
+++ b/apps/desktop/scripts/before-pack.mjs
@@ -110,6 +110,11 @@ export function preserveRollbackBackup(appOutDir, productExeName = 'Hermes.exe')
const backupDir = `${appOutDir}.bak`
try {
rmSync(backupDir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 })
+ // Same non-ASCII rmSync no-op as cleanStaleAppOutDir: a surviving .bak
+ // makes the rename fail and the previous build is wiped instead of kept.
+ if (existsSync(backupDir)) {
+ removeDirSync(backupDir)
+ }
renameSync(appOutDir, backupDir)
return true
} catch {
diff --git a/apps/desktop/scripts/stage-native-deps.mjs b/apps/desktop/scripts/stage-native-deps.mjs
index 5f9a62e7cc1..83f1bc1084a 100644
--- a/apps/desktop/scripts/stage-native-deps.mjs
+++ b/apps/desktop/scripts/stage-native-deps.mjs
@@ -515,11 +515,11 @@ export function stageGetWindowsInto(
)
}
- rmSync(destRoot, { recursive: true, force: true })
+ removeDirSync(destRoot)
mkdirSync(destRoot, { recursive: true })
- cpSync(join(srcRoot, 'package.json'), join(destRoot, 'package.json'))
- cpSync(join(srcRoot, 'index.js'), join(destRoot, 'index.js'))
+ copyFileSync(join(srcRoot, 'package.json'), join(destRoot, 'package.json'))
+ copyFileSync(join(srcRoot, 'index.js'), join(destRoot, 'index.js'))
// lib/*.js only — NOT copyGlobByExt, which recurses into lib/binding and
// stages empty dirs for every prebuilt slot (including the darwin one the
@@ -527,7 +527,7 @@ export function stageGetWindowsInto(
mkdirSync(join(destRoot, 'lib'), { recursive: true })
for (const entry of readdirSync(join(srcRoot, 'lib'), { withFileTypes: true })) {
if (entry.isFile() && entry.name.endsWith('.js')) {
- cpSync(join(srcRoot, 'lib', entry.name), join(destRoot, 'lib', entry.name))
+ copyFileSync(join(srcRoot, 'lib', entry.name), join(destRoot, 'lib', entry.name))
}
}
@@ -538,7 +538,7 @@ export function stageGetWindowsInto(
if (!existsSync(helper)) {
throw new Error('[stage-native-deps] get-windows is missing its macOS helper binary (main)')
}
- cpSync(helper, join(destRoot, 'main'))
+ copyFileSync(helper, join(destRoot, 'main'))
makeExecutable(join(destRoot, 'main'))
}
@@ -592,7 +592,7 @@ export function stageGetWindowsInto(
const dest = join(destRoot, 'lib', 'binding', dir)
mkdirSync(dest, { recursive: true })
const destFile = join(dest, 'node-get-windows.node')
- cpSync(join(bindingRoot, dir, 'node-get-windows.node'), destFile)
+ copyFileSync(join(bindingRoot, dir, 'node-get-windows.node'), destFile)
const classified = classifyNativeBinary(destFile)
if (classified !== platform) {
throw new Error(