forked from aburch/simutrans
-
Notifications
You must be signed in to change notification settings - Fork 1
/
revision.jse
43 lines (32 loc) · 990 Bytes
/
revision.jse
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
var ForReading = 1;
var ForWriting = 2;
var fso = new ActiveXObject("Scripting.FileSystemObject");
var shell = new ActiveXObject("WScript.Shell");
var svnRevNum = shell.Exec("svnversion");
var rev = svnRevNum.StdOut.ReadAll();
var filename = "revision.h";
var file;
var file_ts;
// First, get the file, if it doesn't exist create it.
if( ! fso.FileExists(filename) ) {
fso.CreateTextFile(filename);
file = fso.GetFile(filename);
file_ts = file.OpenAsTextStream(ForWriting,-2);
file_ts.WriteLine("#define REVISION UNDEFINED");
file_ts.Close();
}
else {
file = fso.GetFile(filename);
}
// read it
file_ts = file.OpenAsTextStream(ForReading,-2);
current_line = file_ts.ReadLine() + "\r\n";
file_ts.Close();
new_line = "#define REVISION " + String(rev);
if (new_line != current_line) {
// It has changed, update the .h
WSH.Echo("Svn version updated! " + String(rev));
file_ts = file.OpenAsTextStream(ForWriting,-2);
file_ts.WriteLine(new_line);
file_ts.Close();
}