const fs = require('fs'); const path = require('path'); const { buildLinuxLauncherScript, resolveLinuxLauncherNames } = require('../dist/electron/app/linux-launcher.rules.js'); const LAUNCHER_MODE = 0o755; function installLinuxLauncher(appOutDir, executableName) { const { launcherFileName, binaryFileName } = resolveLinuxLauncherNames(executableName); const launcherPath = path.join(appOutDir, launcherFileName); const binaryPath = path.join(appOutDir, binaryFileName); if (!fs.existsSync(binaryPath)) { fs.renameSync(launcherPath, binaryPath); } fs.writeFileSync(launcherPath, buildLinuxLauncherScript({ binaryFileName }), 'utf8'); fs.chmodSync(launcherPath, LAUNCHER_MODE); return launcherFileName; } exports.default = async function afterPack(context) { if (context.electronPlatformName !== 'linux') { return; } const launcherFileName = installLinuxLauncher(context.appOutDir, context.packager.executableName); console.log(` • linux launcher installed file=${launcherFileName}`); };