1
1
/*
2
2
Feathers UI
3
- Copyright 2020 Bowler Hat LLC. All Rights Reserved.
3
+ Copyright 2024 Bowler Hat LLC. All Rights Reserved.
4
4
5
5
This program is free software. You can redistribute and/or modify it in
6
6
accordance with the terms of the accompanying license agreement.
@@ -17,13 +17,21 @@ import sys.io.File;
17
17
18
18
class PackageHaxelib {
19
19
public static function main (): Void {
20
+ final destDir = FileSystem .absolutePath (" ../bin/haxelib" );
21
+ if (FileSystem .exists (destDir )) {
22
+ deleteDir (destDir );
23
+ }
24
+ FileSystem .createDirectory (destDir );
25
+
26
+ copyFile (FileSystem .absolutePath (" ../haxelib.json" ), destDir );
27
+ copyFile (FileSystem .absolutePath (" ../README.md" ), destDir );
28
+ copyFile (FileSystem .absolutePath (" ../CHANGELOG.md" ), destDir );
29
+ copyFile (FileSystem .absolutePath (" ../LICENSE" ), destDir );
30
+ copyFile (FileSystem .absolutePath (" ../NOTICE" ), destDir );
31
+ copyDir (FileSystem .absolutePath (" ../src" ), destDir );
32
+
20
33
var entries = new List <Entry >();
21
- addFile (FileSystem .absolutePath (" ../haxelib.json" ), entries );
22
- addFile (FileSystem .absolutePath (" ../README.md" ), entries );
23
- addFile (FileSystem .absolutePath (" ../CHANGELOG.md" ), entries );
24
- addFile (FileSystem .absolutePath (" ../LICENSE" ), entries );
25
- addFile (FileSystem .absolutePath (" ../NOTICE" ), entries );
26
- addDirectory (FileSystem .absolutePath (" ../src" ), true , entries );
34
+ addDirectory (destDir , entries );
27
35
28
36
var jsonContent = File .getContent (" ../haxelib.json" );
29
37
var json = Json .parse (jsonContent );
@@ -44,12 +52,47 @@ class PackageHaxelib {
44
52
zip .write (entries );
45
53
}
46
54
55
+ private static function copyFile (filePath : String , destDir : String ): Void {
56
+ var fileName = Path .withoutDirectory (filePath );
57
+ File .copy (filePath , Path .join ([destDir , fileName ]));
58
+ }
59
+
60
+ private static function copyDir (directoryPath : String , destParentDir : String ): Void {
61
+ var dirName = Path .withoutDirectory (directoryPath );
62
+ var destDirPath = Path .join ([destParentDir , dirName ]);
63
+ FileSystem .createDirectory (destDirPath );
64
+ for (fileName in FileSystem .readDirectory (directoryPath )) {
65
+ var filePath = Path .join ([directoryPath , fileName ]);
66
+ if (FileSystem .isDirectory (filePath )) {
67
+ copyDir (filePath , destDirPath );
68
+ } else {
69
+ // extra files on macOS that should be skipped
70
+ if (fileName == " .DS_Store" ) {
71
+ continue ;
72
+ }
73
+ copyFile (filePath , destDirPath );
74
+ }
75
+ }
76
+ }
77
+
78
+ private static function deleteDir (directoryPath : String ): Void {
79
+ for (fileName in FileSystem .readDirectory (directoryPath )) {
80
+ var filePath = Path .join ([directoryPath , fileName ]);
81
+ if (FileSystem .isDirectory (filePath )) {
82
+ deleteDir (filePath );
83
+ } else {
84
+ FileSystem .deleteFile (filePath );
85
+ }
86
+ }
87
+ FileSystem .deleteDirectory (directoryPath );
88
+ }
89
+
47
90
private static function addFile (filePath : String , result : List <Entry >): Void {
48
91
addFileInternal (filePath , Path .directory (filePath ), result );
49
92
}
50
93
51
- private static function addDirectory (directoryPath : String , recursive : Bool , result : List <Entry >): Void {
52
- addDirectoryInternal (directoryPath , Path . directory ( directoryPath ), recursive , result );
94
+ private static function addDirectory (directoryPath : String , result : List <Entry >): Void {
95
+ addDirectoryInternal (directoryPath , directoryPath , result );
53
96
}
54
97
55
98
private static function addFileInternal (filePath : String , relativeToDirPath : String , result : List <Entry >): Void {
@@ -66,13 +109,11 @@ class PackageHaxelib {
66
109
});
67
110
}
68
111
69
- private static function addDirectoryInternal (directoryPath : String , relativeTo : String , recursive : Bool , result : List <Entry >): Void {
112
+ private static function addDirectoryInternal (directoryPath : String , relativeTo : String , result : List <Entry >): Void {
70
113
for (fileName in FileSystem .readDirectory (directoryPath )) {
71
114
var filePath = Path .join ([directoryPath , fileName ]);
72
115
if (FileSystem .isDirectory (filePath )) {
73
- if (recursive ) {
74
- addDirectoryInternal (filePath , relativeTo , true , result );
75
- }
116
+ addDirectoryInternal (filePath , relativeTo , result );
76
117
} else {
77
118
addFileInternal (filePath , relativeTo , result );
78
119
}
0 commit comments