mirror of
https://github.com/bitwarden/browser
synced 2026-02-12 06:23:38 +00:00
feat: automatically cleanup xcode build to avoid duplicate extensions
This commit is contained in:
@@ -2,13 +2,20 @@ const child = require("child_process");
|
||||
const fse = require("fs-extra");
|
||||
|
||||
const paths = {
|
||||
extensionBuild: "./macos/build",
|
||||
macosBuild: "./macos/build",
|
||||
extensionBuild: "./macos/build/Release/autofill-extension.appex",
|
||||
extensionDistDir: "./macos/dist",
|
||||
extensionDist: "./macos/dist/autofill-extension.appex",
|
||||
macOsProject: "./macos/desktop.xcodeproj",
|
||||
};
|
||||
|
||||
async function buildMacOs(cb) {
|
||||
if (fse.existsSync(paths.extensionBuild)) {
|
||||
fse.removeSync(paths.extensionBuild);
|
||||
if (fse.existsSync(paths.macosBuild)) {
|
||||
fse.removeSync(paths.macosBuild);
|
||||
}
|
||||
|
||||
if (fse.existsSync(paths.extensionDistDir)) {
|
||||
fse.removeSync(paths.extensionDistDir);
|
||||
}
|
||||
|
||||
const proc = child.spawn("xcodebuild", [
|
||||
@@ -29,6 +36,11 @@ async function buildMacOs(cb) {
|
||||
resolve();
|
||||
}),
|
||||
);
|
||||
|
||||
fse.mkdirSync(paths.extensionDistDir);
|
||||
fse.copySync(paths.extensionBuild, paths.extensionDist);
|
||||
// Delete the build dir, otherwise MacOS will load the extension from there instead of the Bitwarden.app bundle
|
||||
fse.removeSync(paths.macosBuild);
|
||||
}
|
||||
|
||||
function stdOutProc(proc) {
|
||||
|
||||
@@ -23,12 +23,14 @@ async function run(context) {
|
||||
// cannot use extraFiles because it modifies the extensions .plist and makes it invalid
|
||||
if (copyAutofillExtension) {
|
||||
console.log("### Copying autofill extension");
|
||||
const extensionPath = path.join(__dirname, "../macos/build/Release/autofill-extension.appex");
|
||||
if (fse.existsSync(extensionPath)) {
|
||||
const extensionPath = path.join(__dirname, "../macos/dist/autofill-extension.appex");
|
||||
if (!fse.existsSync(extensionPath)) {
|
||||
console.log("### Autofill extension not found - skipping");
|
||||
} else {
|
||||
fse.mkdirSync(path.join(appPath, "Contents/PlugIns"));
|
||||
fse.copySync(extensionPath, path.join(appPath, "Contents/PlugIns/autofill-extension.appex"));
|
||||
shouldResign = true;
|
||||
}
|
||||
shouldResign = true;
|
||||
}
|
||||
|
||||
if (copySafariExtension) {
|
||||
|
||||
Reference in New Issue
Block a user