11/*
22 Feathers UI
3- Copyright 2020 Bowler Hat LLC. All Rights Reserved.
3+ Copyright 2024 Bowler Hat LLC. All Rights Reserved.
44
55 This program is free software. You can redistribute and/or modify it in
66 accordance with the terms of the accompanying license agreement.
@@ -17,13 +17,21 @@ import sys.io.File;
1717
1818class PackageHaxelib {
1919 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+
2033 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 );
2735
2836 var jsonContent = File .getContent (" ../haxelib.json" );
2937 var json = Json .parse (jsonContent );
@@ -44,12 +52,47 @@ class PackageHaxelib {
4452 zip .write (entries );
4553 }
4654
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+
4790 private static function addFile (filePath : String , result : List <Entry >): Void {
4891 addFileInternal (filePath , Path .directory (filePath ), result );
4992 }
5093
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 );
5396 }
5497
5598 private static function addFileInternal (filePath : String , relativeToDirPath : String , result : List <Entry >): Void {
@@ -66,13 +109,11 @@ class PackageHaxelib {
66109 });
67110 }
68111
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 {
70113 for (fileName in FileSystem .readDirectory (directoryPath )) {
71114 var filePath = Path .join ([directoryPath , fileName ]);
72115 if (FileSystem .isDirectory (filePath )) {
73- if (recursive ) {
74- addDirectoryInternal (filePath , relativeTo , true , result );
75- }
116+ addDirectoryInternal (filePath , relativeTo , result );
76117 } else {
77118 addFileInternal (filePath , relativeTo , result );
78119 }
0 commit comments