Skip to content

Commit

Permalink
conditional for checkRec to not return dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
mastef committed Feb 9, 2018
1 parent 6e09f72 commit c91c109
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/haxelib/client/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1291,7 +1291,7 @@ class Main {
print("Library "+prj+" current version is now "+version);
}

function checkRec( rep : String, prj : String, version : String, l : List<{ project : String, version : String, dir : String, info : Infos }> ) {
function checkRec( rep : String, prj : String, version : String, l : List<{ project : String, version : String, dir : String, info : Infos }>, ?returnDependencies : Bool = true ) {
var pdir = rep + Data.safe(prj);
if( !FileSystem.exists(pdir) )
throw "Library "+prj+" is not installed : run 'haxelib install "+prj+"'";
Expand All @@ -1312,17 +1312,19 @@ class Main {
var json = try File.getContent(vdir+"/"+Data.JSON) catch( e : Dynamic ) null;
var inf = Data.readData(json,false);
l.add({ project : prj, version : version, dir : Path.addTrailingSlash(vdir), info: inf });
for( d in inf.dependencies )
if( !Lambda.exists(l, function(e) return e.project == d.name) )
checkRec(rep,d.name,if( d.version == "" ) null else d.version,l);
if( returnDependencies ) {
for( d in inf.dependencies )
if( !Lambda.exists(l, function(e) return e.project == d.name) )
checkRec(rep,d.name,if( d.version == "" ) null else d.version,l);
}
}

function path() {
var rep = getRepository();
var list = new List();
while( argcur < args.length ) {
var a = args[argcur++].split(":");
checkRec(rep, a[0],a[1],list);
checkRec(rep, a[0], a[1], list);
}
for( d in list ) {
var ndir = d.dir + "ndll";
Expand Down Expand Up @@ -1350,7 +1352,7 @@ class Main {
while( argcur < args.length ) {
var a = args[argcur++].split(":");
var results = new List();
checkRec(rep, a[0],a[1],results);
checkRec(rep, a[0], a[1], results, false);
if( !results.isEmpty() ) Sys.println(results.first().dir);

This comment has been minimized.

Copy link
@kLabz

kLabz Feb 9, 2018

Contributor

Is .first() still needed here now that checkRec do not include dependencies?

This comment has been minimized.

Copy link
@mastef

mastef Feb 9, 2018

Author Contributor

Yes, since a list is returned

}
}
Expand Down

0 comments on commit c91c109

Please sign in to comment.