77 existsSync ,
88 mkdirSync ,
99 readFileSync ,
10- readdirSync ,
1110 rmSync ,
1211 statSync ,
1312 writeFileSync ,
@@ -19,7 +18,7 @@ import { fileURLToPath } from "node:url";
1918const isDevelopment = Boolean ( process . env . VITE_DEV_SERVER_URL ) ;
2019const APP_DISPLAY_NAME = isDevelopment ? "MarCode (Dev)" : "MarCode (Alpha)" ;
2120const APP_BUNDLE_ID = isDevelopment ? "com.marcode.marcode.dev" : "com.marcode.marcode" ;
22- const LAUNCHER_VERSION = 1 ;
21+ const LAUNCHER_VERSION = 2 ;
2322
2423const __dirname = dirname ( fileURLToPath ( import . meta. url ) ) ;
2524export const desktopDir = resolve ( __dirname , ".." ) ;
@@ -55,40 +54,6 @@ function patchMainBundleInfoPlist(appBundlePath, iconPath) {
5554 copyFileSync ( iconPath , join ( resourcesDir , "electron.icns" ) ) ;
5655}
5756
58- function patchHelperBundleInfoPlists ( appBundlePath ) {
59- const frameworksDir = join ( appBundlePath , "Contents" , "Frameworks" ) ;
60- if ( ! existsSync ( frameworksDir ) ) {
61- return ;
62- }
63-
64- for ( const entry of readdirSync ( frameworksDir , { withFileTypes : true } ) ) {
65- if ( ! entry . isDirectory ( ) || ! entry . name . endsWith ( ".app" ) ) {
66- continue ;
67- }
68- if ( ! entry . name . startsWith ( "Electron Helper" ) ) {
69- continue ;
70- }
71-
72- const helperPlistPath = join ( frameworksDir , entry . name , "Contents" , "Info.plist" ) ;
73- if ( ! existsSync ( helperPlistPath ) ) {
74- continue ;
75- }
76-
77- const suffix = entry . name . replace ( "Electron Helper" , "" ) . replace ( ".app" , "" ) . trim ( ) ;
78- const helperName = suffix
79- ? `${ APP_DISPLAY_NAME } Helper ${ suffix } `
80- : `${ APP_DISPLAY_NAME } Helper` ;
81- const helperIdSuffix = suffix . replace ( / [ ( ) ] / g, "" ) . trim ( ) . toLowerCase ( ) . replace ( / \s + / g, "-" ) ;
82- const helperBundleId = helperIdSuffix
83- ? `${ APP_BUNDLE_ID } .helper.${ helperIdSuffix } `
84- : `${ APP_BUNDLE_ID } .helper` ;
85-
86- setPlistString ( helperPlistPath , "CFBundleDisplayName" , helperName ) ;
87- setPlistString ( helperPlistPath , "CFBundleName" , helperName ) ;
88- setPlistString ( helperPlistPath , "CFBundleIdentifier" , helperBundleId ) ;
89- }
90- }
91-
9257function readJson ( path ) {
9358 try {
9459 return JSON . parse ( readFileSync ( path , "utf8" ) ) ;
@@ -126,7 +91,6 @@ function buildMacLauncher(electronBinaryPath) {
12691 rmSync ( targetAppBundlePath , { recursive : true , force : true } ) ;
12792 cpSync ( sourceAppBundlePath , targetAppBundlePath , { recursive : true } ) ;
12893 patchMainBundleInfoPlist ( targetAppBundlePath , iconPath ) ;
129- patchHelperBundleInfoPlists ( targetAppBundlePath ) ;
13094 writeFileSync ( metadataPath , `${ JSON . stringify ( expectedMetadata , null , 2 ) } \n` ) ;
13195
13296 return targetBinaryPath ;
@@ -140,5 +104,11 @@ export function resolveElectronPath() {
140104 return electronBinaryPath ;
141105 }
142106
107+ // Dev launches do not need a renamed app bundle badly enough to risk breaking
108+ // Electron helper resource lookup on macOS.
109+ if ( isDevelopment ) {
110+ return electronBinaryPath ;
111+ }
112+
143113 return buildMacLauncher ( electronBinaryPath ) ;
144114}
0 commit comments