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

Display current repository path when using haxelib list #634

Open
wants to merge 11 commits into
base: development
Choose a base branch
from
Open
Binary file modified run.n
Binary file not shown.
4 changes: 4 additions & 0 deletions src/haxelib/api/GlobalScope.hx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package haxelib.api;

import sys.FileSystem;
import sys.io.File;
import haxe.ds.GenericStack;
import haxe.io.Path;
Expand All @@ -21,6 +22,9 @@ using StringTools;
class GlobalScope extends Scope {
function new(repository:Repository) {
super(false, repository);

// While this class is "GlobalScope", there's currently not a "LocalScope" equivalent class. For now we can add this here.
isLocal = FileSystem.exists("./.haxelib");
}

public function runScript(library:ProjectName, ?callData:CallData, ?version:Version):Void {
Expand Down
19 changes: 15 additions & 4 deletions src/haxelib/client/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -553,21 +553,32 @@ class Main {

// sort projects alphabetically
libraryInfo.sort(function(a, b) return Reflect.compare(a.name.toLowerCase(), b.name.toLowerCase()));

// we want to print in one batch, rather than one cli print for each line
var listStr = '';

if (scope.isLocal)
listStr += 'Local Haxelib Repository at: ${RepoManager.getLocalPath("./")}\n';
else
listStr += 'Global Haxelib at: ${RepoManager.getGlobalPath()}\n';

for (library in libraryInfo) {
var line = '${library.name}:';
listStr += '${library.name}:';
for (version in library.versions)
line +=
listStr +=
if (library.devPath == null && version == library.current)
' [$version]'
else
' $version';

if (library.devPath != null)
line += ' [dev:${library.devPath}]';
listStr += ' [dev:${library.devPath}]';

listStr += "\n";

Cli.print(line);
}
Cli.print(listStr);

}

function update() {
Expand Down