From 8d4b5151b5e15109c0d9cd908dce808ad4db35f8 Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Mon, 22 May 2017 11:51:14 -0700 Subject: [PATCH] Add support for 'haxelib path lib:ver' using git, hg, etc directories --- tools/haxelib/client/Main.hx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tools/haxelib/client/Main.hx b/tools/haxelib/client/Main.hx index 259c0ff8c..4d3a43680 100644 --- a/tools/haxelib/client/Main.hx +++ b/tools/haxelib/client/Main.hx @@ -1086,16 +1086,23 @@ class Main { continue; v = Data.unsafe(v); var semver = try SemVer.ofString(v) catch (_:Dynamic) null; + if ( semver == null ) { + var json = try File.getContent(dir+"/"+v+"/"+Data.JSON) catch( e : Dynamic ) null; + if ( json != null ) { + var inf = Data.readData(json, false); + semver = try SemVer.ofString(inf.version) catch (_:Dynamic) null; + } + } if (semver != null && matchVersion(version, semver)) - matches.push(semver); + matches.push({ dir: v, ver: semver }); } - var best = null; + var best:Dynamic = null; for( match in matches ) { - if (best == null || match > best) { + if (best == null || match.ver > best.ver) { best = match; } } - return if (best != null) dir + "/" + Data.safe(best) else null; + return if (best != null) dir + "/" + Data.safe(best.dir) else null; } function list() {