forked from TheRealJake12/Kade-Engine-Community
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUpdate.hx
46 lines (42 loc) · 1.46 KB
/
Update.hx
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
import haxe.Json;
import sys.io.File;
import sys.FileSystem;
class Update {
public static function main() {
// to prevent messing with currently installed libs
if (!FileSystem.exists('.haxelib'))
FileSystem.createDirectory('.haxelib');
var json:Array<Library> = Json.parse(File.getContent('./hmm.json')).dependencies;
prettyPrint("Preparing installation...");
for(lib in json) {
// install libs
switch(lib.type) {
case "haxelib":
prettyPrint('Installing "${lib.name}"...');
Sys.command('haxelib install ${lib.name} ${lib.version != null ? " " + lib.version : " "}');
case "git":
prettyPrint('Installing "${lib.name}" from git url "${lib.url}"');
Sys.command('haxelib git ${lib.name} ${lib.url}');
default:
prettyPrint('Cannot resolve library of type "${lib.type}"');
}
}
}
public static function prettyPrint(text:String) {
var header = "══════";
for(i in 0...text.length)
header += "═";
Sys.println("");
Sys.println('╔$header╗');
Sys.println('║ $text ║');
Sys.println('╚$header╝');
}
}
typedef Library = {
var name:String;
var type:String;
var version:String;
var dir:String;
var ref:String;
var url:String;
}