diff --git a/scripts.hxml b/scripts.hxml index ffa8ea1..204d248 100644 --- a/scripts.hxml +++ b/scripts.hxml @@ -1,2 +1,3 @@ --class-path scripts --class-path src +--library tink_core diff --git a/scripts/Clean.hx b/scripts/Clean.hx index 3307385..c4931eb 100644 --- a/scripts/Clean.hx +++ b/scripts/Clean.hx @@ -1,9 +1,22 @@ import sys.FileSystem; using Lambda; +using haxe.io.Path; /** Deletes all generated files. **/ function main() { ["js", "js.map"].map(ext -> 'bin/setup_hashlink.$ext').filter(FileSystem.exists).iter(FileSystem.deleteFile); - ["lib", "res"].filter(FileSystem.exists).iter(Tools.removeDirectory); - Tools.cleanDirectory("var"); + ["lib", "res"].filter(FileSystem.exists).iter(removeDirectory); + cleanDirectory("var"); +} + +/** Recursively deletes all files in the specified `directory`. **/ +private function cleanDirectory(directory: String) for (entry in FileSystem.readDirectory(directory).filter(entry -> entry != ".gitkeep")) { + final path = Path.join([directory, entry]); + FileSystem.isDirectory(path) ? removeDirectory(path) : FileSystem.deleteFile(path); +} + +/** Recursively deletes the specified `directory`. **/ +private function removeDirectory(directory: String) { + cleanDirectory(directory); + FileSystem.deleteDirectory(directory); } diff --git a/scripts/Tools.hx b/scripts/Tools.hx deleted file mode 100644 index 45de426..0000000 --- a/scripts/Tools.hx +++ /dev/null @@ -1,20 +0,0 @@ -import sys.FileSystem; -import sys.io.File; -using DateTools; -using haxe.io.Path; - -/** Recursively deletes all files in the specified `directory`. **/ -function cleanDirectory(directory: String) for (entry in FileSystem.readDirectory(directory).filter(entry -> entry != ".gitkeep")) { - final path = Path.join([directory, entry]); - FileSystem.isDirectory(path) ? removeDirectory(path) : FileSystem.deleteFile(path); -} - -/** Recursively deletes the specified `directory`. **/ -function removeDirectory(directory: String) { - cleanDirectory(directory); - FileSystem.deleteDirectory(directory); -} - -/** Replaces in the specified `file` the substring which the `pattern` matches with the given `replacement`. **/ -function replaceInFile(file: String, pattern: EReg, replacement: String) - File.saveContent(file, pattern.replace(File.getContent(file), replacement)); diff --git a/scripts/Version.hx b/scripts/Version.hx index 6cac820..8fd8921 100644 --- a/scripts/Version.hx +++ b/scripts/Version.hx @@ -1,8 +1,13 @@ //! --class-path src --library tink_core import setup_hashlink.Platform; +import sys.io.File; /** Updates the version number in the sources. **/ function main() { - Tools.replaceInFile("package.json", ~/"version": "\d+(\.\d+){2}"/, '"version": "${Platform.packageVersion}"'); - Tools.replaceInFile("README.md", ~/action\/v\d+(\.\d+){2}/, 'action/v${Platform.packageVersion}'); + replaceInFile("package.json", ~/"version": "\d+(\.\d+){2}"/, '"version": "${Platform.packageVersion}"'); + replaceInFile("README.md", ~/action\/v\d+(\.\d+){2}/, 'action/v${Platform.packageVersion}'); } + +/** Replaces in the specified `file` the substring which the `pattern` matches with the given `replacement`. **/ +private function replaceInFile(file: String, pattern: EReg, replacement: String) + File.saveContent(file, pattern.replace(File.getContent(file), replacement));