-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSubmit.hx
52 lines (46 loc) · 1.59 KB
/
Submit.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
47
48
49
50
51
52
//====================================================================
// * Haxe to GDScript Submit Script
//
// Haxelib is dumb and only allows for one class path, so this
// script merges all the class paths (`src`, `std`, `std/gdscript/_std`)
// into a single folder to help with haxelib submission.
//====================================================================
package;
import sys.io.File;
import haxe.io.Path;
class Submit {
public static function main() {
if(sys.FileSystem.exists("_submit")) throw "'Folder /_submit/ should not exist before running this script.'";
makeDirIfNonExist("_submit");
copyDirContent("src", "_submit");
copyDirContent("std", "_submit", "std/gdscript/_std");
copyDirContent("std/gdscript/_std", "_submit", "", ".cross.hx");
}
static function makeDirIfNonExist(p: String) {
if(!sys.FileSystem.exists(p)) {
sys.FileSystem.createDirectory(p);
}
}
static function copyDirContent(from: String, to: String, ignore: String = "", replaceExt: Null<String> = null) {
if(sys.FileSystem.exists(from)) {
for(file in sys.FileSystem.readDirectory(from)) {
final path = Path.join([from, file]);
var dest = Path.join([to, file]);
if(!sys.FileSystem.isDirectory(path)) {
if(replaceExt != null) {
dest = Path.withoutExtension(dest) + replaceExt;
}
File.copy(path, dest);
} else {
if(ignore.length > 0 && ignore == path) {
return;
}
final d = Path.addTrailingSlash(path);
final d2 = Path.addTrailingSlash(dest);
makeDirIfNonExist(d2);
copyDirContent(d, d2, ignore, replaceExt);
}
}
}
}
}