Skip to content

Commit

Permalink
Update the build system
Browse files Browse the repository at this point in the history
  • Loading branch information
cedx committed Aug 28, 2024
1 parent 542ae13 commit ede08be
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 24 deletions.
1 change: 1 addition & 0 deletions scripts.hxml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
--class-path scripts
--class-path src
--library tink_core
17 changes: 15 additions & 2 deletions scripts/Clean.hx
Original file line number Diff line number Diff line change
@@ -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);
}
20 changes: 0 additions & 20 deletions scripts/Tools.hx

This file was deleted.

9 changes: 7 additions & 2 deletions scripts/Version.hx
Original file line number Diff line number Diff line change
@@ -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));

0 comments on commit ede08be

Please sign in to comment.