1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-11 14:04:03 +00:00
Files
browser/apps/desktop/scripts/before-pack.js
2025-01-14 22:09:53 -05:00

40 lines
1.2 KiB
JavaScript

/* eslint-disable @typescript-eslint/no-require-imports, no-console */
const { Platform } = require("electron-builder");
const path = require("path");
const fse = require("fs-extra");
exports.default = run;
async function run(context) {
console.log("## Before pack");
const platform = context.packager.platform;
const targets = context.packager.targets;
console.log("### Platform: " + platform);
console.log("### Targets: " + targets);
const isSnap = platform === Platform.LINUX && targets.includes("snap");
if (isSnap) {
console.log("### Copying polkit policy file");
const policyPath = path.join(__dirname, "../resources/com.bitwarden.desktop.policy");
const targetDir = path.join(context.appOutDir, "/meta/polkit");
if (fse.existsSync(policyPath)) {
if (!fse.existsSync(targetDir)) {
console.log("### Creating polkit directory " + targetDir);
fse.mkdirSync(targetDir);
}
console.log("### Copying polkit policy file to " + targetDir);
fse.copySync(policyPath, targetDir);
} else {
console.log("### Policy file not found - skipping");
}
} else {
console.log("### Skipping polkit policy file copy because not a snap build");
}
}