minor cleanup of make_scmrev.h.js

This commit is contained in:
Jordan Woyak 2011-08-21 22:25:52 -05:00
parent 0090c9db9e
commit a910f97c39
1 changed files with 11 additions and 18 deletions

View File

@ -8,26 +8,20 @@ var cmd_branch = " rev-parse --abbrev-ref HEAD";
function GetGitExe() function GetGitExe()
{ {
var gitexe = "git.cmd"; for (var gitexe in {"git.cmd":1, "git":1})
try
{
wshShell.Exec(gitexe);
}
catch (e)
{ {
try try
{ {
gitexe = "git";
wshShell.Exec(gitexe); wshShell.Exec(gitexe);
return gitexe;
} }
catch (e) catch (e)
{ {}
WScript.Echo("Cannot find git or git.cmd, check your PATH:\n" +
wshShell.ExpandEnvironmentStrings("%PATH%"));
WScript.Quit(1);
}
} }
return gitexe;
WScript.Echo("Cannot find git or git.cmd, check your PATH:\n" +
wshShell.ExpandEnvironmentStrings("%PATH%"));
WScript.Quit(1);
} }
function GetFirstStdOutLine(cmd) function GetFirstStdOutLine(cmd)
@ -52,9 +46,8 @@ function GetFileContents(f)
} }
catch (e) catch (e)
{ {
// file doesn't exist or string not found, (re)create it // file doesn't exist
oFS.CreateTextFile(f); return "";
return 0;
} }
} }
@ -77,11 +70,11 @@ var out_contents =
// check if file needs updating // check if file needs updating
if (out_contents == GetFileContents(outfile)) if (out_contents == GetFileContents(outfile))
{ {
WScript.Echo(outfile + " doesn't need updating (already at " + revision + ")"); WScript.Echo(outfile + " current at " + revision);
} }
else else
{ {
// needs updating - writeout current info // needs updating - writeout current info
oFS.CreateTextFile(outfile, true).Write(out_contents); oFS.CreateTextFile(outfile, true).Write(out_contents);
WScript.Echo(outfile + " updated (" + revision + ")"); WScript.Echo(outfile + " updated to " + revision);
} }