Refactor patch-windows-binaries script to improve error handling and target specific executables
Some checks reported errors
farmcontrol/farmcontrol-ui/pipeline/head Something is wrong with the build of this commit
Some checks reported errors
farmcontrol/farmcontrol-ui/pipeline/head Something is wrong with the build of this commit
- Replaced the dynamic executable discovery with a predefined set of target executables (`launcher.exe`, `deeplink.exe`) for clarity. - Added checks to skip missing executables and improved error handling during the patching process, enhancing robustness and user feedback.
This commit is contained in:
parent
634113ec5c
commit
2e7d255b20
@ -1,9 +1,9 @@
|
|||||||
import { existsSync, readdirSync } from 'node:fs'
|
import { existsSync } from 'node:fs'
|
||||||
import path from 'node:path'
|
import path from 'node:path'
|
||||||
import { fileURLToPath } from 'node:url'
|
import { fileURLToPath } from 'node:url'
|
||||||
import rcedit from 'rcedit'
|
import rcedit from 'rcedit'
|
||||||
|
|
||||||
const rootDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
|
const PATCH_TARGETS = new Set(['launcher.exe', 'deeplink.exe'])
|
||||||
|
|
||||||
export async function patchWindowsBinaries(appDir) {
|
export async function patchWindowsBinaries(appDir) {
|
||||||
if (process.platform !== 'win32') {
|
if (process.platform !== 'win32') {
|
||||||
@ -15,16 +15,24 @@ export async function patchWindowsBinaries(appDir) {
|
|||||||
throw new Error(`patch-windows-binaries: bin directory not found at ${binDir}`)
|
throw new Error(`patch-windows-binaries: bin directory not found at ${binDir}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const executables = readdirSync(binDir).filter((name) =>
|
for (const executable of PATCH_TARGETS) {
|
||||||
name.toLowerCase().endsWith('.exe')
|
|
||||||
)
|
|
||||||
|
|
||||||
for (const executable of executables) {
|
|
||||||
const executablePath = path.join(binDir, executable)
|
const executablePath = path.join(binDir, executable)
|
||||||
|
if (!existsSync(executablePath)) {
|
||||||
|
console.warn(`patch-windows-binaries: skipping missing ${executablePath}`)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
await rcedit(executablePath, {
|
await rcedit(executablePath, {
|
||||||
'requested-execution-level': 'asInvoker'
|
'requested-execution-level': 'asInvoker'
|
||||||
})
|
})
|
||||||
console.log(`patch-windows-binaries: set asInvoker on ${executablePath}`)
|
console.log(`patch-windows-binaries: set asInvoker on ${executablePath}`)
|
||||||
|
} catch (error) {
|
||||||
|
console.warn(
|
||||||
|
`patch-windows-binaries: failed to patch ${executablePath}:`,
|
||||||
|
error instanceof Error ? error.message : error
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user