Browse Source

rewrite git/cmd to git/bin

Simon Krajewski 13 years ago
parent
commit
dd980ea7d3
1 changed files with 17 additions and 4 deletions
  1. 17 4
      std/tools/haxelib/Main.hx

+ 17 - 4
std/tools/haxelib/Main.hx

@@ -750,11 +750,24 @@ class Main {
 	}
 
 	function git() {
-		try command("git", [])
-		catch (e:Dynamic)
+		var gitExists = function()
+			try { command("git", []); return true; } catch (e:Dynamic) return false;
+		if (!gitExists())
 		{
-			print("Could not execute git, please make sure it is installed and available in your PATH.");
-			return;
+			var match = ~/(.*)git([\\|\/])cmd$/ ;
+			for (path in Sys.getEnv("PATH").split(";"))
+			{
+				if (match.match(path.toLowerCase()))
+				{
+					var newPath = match.matched(1) + "git" +match.matched(2) + "bin";
+					Sys.putEnv("PATH", Sys.getEnv("PATH") + ";" +newPath);
+				}
+			}
+			if (!gitExists())
+			{
+				print("Could not execute git, please make sure it is installed and available in your PATH.");
+				return;
+			}
 		}
 		var libName = param("Library name");
 		var rep = getRepository();