diff --git a/build-helpers/ensure-mac-dependency.js b/build-helpers/ensure-mac-dependency.js index 84109ed3..4826d53f 100644 --- a/build-helpers/ensure-mac-dependency.js +++ b/build-helpers/ensure-mac-dependency.js @@ -9,38 +9,43 @@ const packages = [ // Add more packages here if needed ]; -const isMac = os.platform() === 'darwin'; -packages.forEach((packageName) => { - const packagePath = path.join(__dirname, '..', 'node_modules', packageName); +exports.default = function () { + console.log('Checking for macOS dependencies...'); - if (isMac) { + const isMac = os.platform() === 'darwin'; + + packages.forEach((packageName) => { + const packagePath = path.join(__dirname, '..', 'node_modules', packageName); + + if (isMac) { // On macOS, ensure that the package is installed - if (!fs.existsSync(packagePath)) { - console.log(`macOS detected and ${packageName} is not installed. Installing...`); - try { - execSync(`npm install ${packageName}`, { stdio: 'inherit' }); - console.log(`${packageName} installed successfully.`); - } catch (error) { - console.error(`Failed to install ${packageName} on macOS:`, error); - process.exit(1); + if (!fs.existsSync(packagePath)) { + console.log(`macOS detected and ${packageName} is not installed. Installing...`); + try { + execSync(`npm install ${packageName}`, { stdio: 'inherit' }); + console.log(`${packageName} installed successfully.`); + } catch (error) { + console.error(`Failed to install ${packageName} on macOS:`, error); + process.exit(1); + } + } else { + console.log(`macOS detected and ${packageName} is already installed. No action needed.`); } } else { - console.log(`macOS detected and ${packageName} is already installed. No action needed.`); - } - } else { // On non-macOS platforms, ensure that the package is not present - if (fs.existsSync(packagePath)) { - console.log(`Non-macOS platform detected and ${packageName} is present. Removing...`); - try { - execSync(`npm uninstall ${packageName}`, { stdio: 'inherit' }); - console.log(`${packageName} removed successfully.`); - } catch (error) { - console.error(`Failed to uninstall ${packageName} on non-mac platform:`, error); - process.exit(1); + if (fs.existsSync(packagePath)) { + console.log(`Non-macOS platform detected and ${packageName} is present. Removing...`); + try { + execSync(`npm uninstall ${packageName}`, { stdio: 'inherit' }); + console.log(`${packageName} removed successfully.`); + } catch (error) { + console.error(`Failed to uninstall ${packageName} on non-mac platform:`, error); + process.exit(1); + } + } else { + console.log(`Non-macOS platform detected and ${packageName} is not installed. No action needed.`); } - } else { - console.log(`Non-macOS platform detected and ${packageName} is not installed. No action needed.`); } - } -}); + }); +}; diff --git a/electron-builder.yml b/electron-builder.yml index 6d3c06b1..d64bf288 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -62,3 +62,5 @@ protocols: asarUnpack: - ./assets/images/taskbar + +beforeBuild: ./build-helpers/ensure-mac-dependency.js diff --git a/package.json b/package.json index 869e65ea..fb7d1675 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "buildPackges": "npx lerna run build", "packages": "npx lerna publish --no-git-tag-version", "uidev": "cd uidev && webpack-dev-server", - "postinstall": "npx lerna run prepare && node ./build-helpers/ensure-mac-dependency.js" + "postinstall": "npx lerna run prepare" }, "keywords": [], "author": "Stefan Malzner ",