diff --git a/shallow_backup/backup.py b/shallow_backup/backup.py index 5b0f8792..7eebcb29 100644 --- a/shallow_backup/backup.py +++ b/shallow_backup/backup.py @@ -138,13 +138,22 @@ def run_cmd_if_no_dry_run(command, dest, dry_run) -> int: if not dry_run: overwrite_dir_prompt_if_needed(backup_path, skip) - for mgr in ["brew", "brew cask", "gem"]: + for mgr in ["gem"]: # deal with package managers that have spaces in them. print_pkg_mgr_backup(mgr) command = f"{mgr} list" dest = f"{backup_path}/{mgr.replace(' ', '-')}_list.txt" run_cmd_if_no_dry_run(command, dest, dry_run) + # brew + print_pkg_mgr_backup("brew") + command = f"brew bundle dump --file {backup_path}/brew_list.txt" + dest = f"{backup_path}/brew_list.txt" + if not dry_run: + ret = run_cmd(command) + if not ret: + print_yellow("Package manager not present.") + # cargo print_pkg_mgr_backup("cargo") command = "ls {}".format(home_prefix(".cargo/bin/")) diff --git a/shallow_backup/reinstall.py b/shallow_backup/reinstall.py index b52d2be6..e338ce60 100644 --- a/shallow_backup/reinstall.py +++ b/shallow_backup/reinstall.py @@ -124,7 +124,7 @@ def run_cmd_if_no_dry_run(command, dry_run) -> int: package_mgrs = set() for file in os.listdir(packages_path): manager = file.split("_")[0].replace("-", " ") - if manager in ["gem", "brew-cask", "cargo", "npm", "pip", "pip3", "brew", "vscode", "apm", "macports"]: + if manager in ["gem", "cargo", "npm", "pip", "pip3", "brew", "vscode", "apm", "macports"]: package_mgrs.add(file.split("_")[0]) print_blue_bold("Package Manager Backups Found:") @@ -135,10 +135,9 @@ def run_cmd_if_no_dry_run(command, dry_run) -> int: # TODO: Multithreading for reinstallation. # Construct reinstallation commands and execute them for pm in package_mgrs: - if pm in ["brew", "brew-cask"]: - pm_formatted = pm.replace("-", " ") - print_pkg_mgr_reinstall(pm_formatted) - cmd = f"xargs {pm.replace('-', ' ')} install < {packages_path}/{pm_formatted}_list.txt" + if pm == "brew": + print_pkg_mgr_reinstall(pm) + cmd = f"brew bundle install --no-lock --file {packages_path}/brew_list.txt" run_cmd_if_no_dry_run(cmd, dry_run) elif pm == "npm": print_pkg_mgr_reinstall(pm)