From 9ca3a9d13abdbe2ec68abc8b437f9d53ddbb0022 Mon Sep 17 00:00:00 2001 From: mcraa <6892971+mcraa@users.noreply.github.com> Date: Tue, 14 Feb 2023 19:25:54 +0100 Subject: [PATCH] patch: use @electron/remote for locating rpiboot files --- webpack.config.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/webpack.config.ts b/webpack.config.ts index 8f281a7b..4f358f32 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -276,6 +276,26 @@ const commonConfig = { `, replace: "require('./build/Release/Generator.node')", }), + replace(/node_modules\/node-raspberrypi-usbboot\/build\/index\.js$/, { + search: + "return await readFile(Path.join(__dirname, '..', 'blobs', filename));", + replace: outdent` + const remote = require('@electron/remote'); + return await readFile( + Path.join( + // With macOS universal builds, getAppPath() returns the path to an app.asar file containing an index.js file which will + // include the app-x64 or app-arm64 folder depending on the arch. + // We don't care about the app.asar file, we want the actual folder. + remote.app.getAppPath().replace(/\\.asar$/, () => process.platform === 'darwin' ? '-' + process.arch : ''), + 'generated', + __dirname.replace('node_modules', 'modules'), + '..', + 'blobs', + filename + ) + ); + `, + }), // Copy native modules to generated folder { test: /\.node$/,