Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for attempting to remove a lib when dev is set #644

Open
wants to merge 5 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified run.n
Binary file not shown.
13 changes: 12 additions & 1 deletion src/haxelib/api/Repository.hx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package haxelib.api;

import haxelib.client.Cli;
import haxelib.VersionData.VcsData;
import sys.FileSystem;
import sys.io.File;
Expand Down Expand Up @@ -169,7 +170,9 @@ class Repository {
throw 'Library $name version $version is not installed';

final current = getCurrentFileContent(name);
if (current == version)
final installationInfo = getProjectInstallationInfo(name);

if (installationInfo.devPath == null && current == version)
throw 'Cannot remove current version of library $name';

try {
Expand All @@ -180,6 +183,14 @@ class Repository {
}

FsUtils.deleteRec(versionPath);

// Dev path is set here definitely, since we've had a previous check earlier that would throw if this and dev path were true
if (current == version)
{
var latestVersion = installationInfo.versions.pop();
setCurrentVersion(name, latestVersion);
}

}

/** Throws an error if removing `versionPath` conflicts with the dev path of library `name` **/
Expand Down