-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.d
47 lines (45 loc) · 1.18 KB
/
update.d
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
44
45
46
47
/* Usage:
* rdmd update.d [path] [files (optional)]
*
* Examples:
*
* // Update all betterr core files
* rdmd update.d /home/phil/test
*
* // Update only ts.d
* rdmd update.d /home/phil/test ts
*
* // Update ts.d and array.d
* rdmd update.d /home/phil/test ts array */
import std.algorithm, std.array, std.file, std.path;
import std.process, std.stdio, std.string;
void main(string[] args) {
assert(args.length > 1, "You need to supply an installation directory");
if (args.length == 2) {
writeln("Updating all betterr core files");
foreach(src; sourceFiles) {
string fn = args[1] ~ "/betterr/" ~ setExtension(src, "d");
if (exists(fn)) {
remove(fn);
}
copy(src, fn);
}
} else {
writeln("Updating only these core files: ", args[2..$]);
foreach(src; args[2..$]) {
string fn = args[1] ~ "/betterr/" ~ setExtension(src, "d");
writeln(fn);
if (exists(fn)) {
remove(fn);
}
copy(setExtension(src, "d"), fn);
}
}
}
string[] sourceFiles() {
return dirEntries(".", "*.d", SpanMode.shallow)
.filter!(a => a.isFile)
.filter!(a => (a != "install.d") && (a != "update.d"))
.map!((return a) => baseName(a.name))
.array;
}