Skip to content
This repository has been archived by the owner on Jan 4, 2020. It is now read-only.

Marathon remove --all-packages causes multiple updates #78

Open
JohnSundell opened this issue May 29, 2017 · 1 comment
Open

Marathon remove --all-packages causes multiple updates #78

JohnSundell opened this issue May 29, 2017 · 1 comment

Comments

@JohnSundell
Copy link
Owner

JohnSundell commented May 29, 2017

When running marathon remove --all-packages, multiple swift package update commands are performed under the hood, making the removal take longer than needed. Ideally only one update should occur, at the end of the process.

Current behavior:

$ marathon remove --all-packages
🏃  Removing Files...
    Updating packages...
    Removing Releases...
    Updating packages...
    Removing ShellOut...
    Updating packages...
    Removing Xgen...
    Updating packages...
    Updating packages...
🗑  Removed all packages

Expected behavior:

$ marathon remove --all-packages
🏃  Removing Files...
    Removing Releases...
    Removing ShellOut...
    Removing Xgen...
    Updating packages...
🗑  Removed all packages
@ghost
Copy link

ghost commented Aug 19, 2018

Hi @JohnSundell

It looks like this is an issue with a default paramter. The following calls removePackage(named:) in a for loop, so the default is true.

func removeAllPackages() throws {
     for package in addedPackages {
        try removePackage(named: package.name)
     }
    try updatePackages()
}
func removePackage(named name: String, shouldUpdatePackages: Bool = true) throws -> Package {
        output.progress("Removing \(name)...")

        let packageFile = try perform(folder.file(named: name),
                                      orThrow: Error.unknownPackageForRemoval(name))

        let package = try perform(unbox(data: packageFile.read()) as Package,
                                  orThrow: Error.failedToReadPackageFile(name))

        try perform(packageFile.delete(), orThrow: Error.failedToRemovePackage(name, folder))

        if shouldUpdatePackages {
            try updatePackages()
        }

        return package
    }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant