make libPath part of Prelude

This commit is contained in:
2021-10-22 16:26:19 -04:00
parent e16a37044a
commit 40e686f95e
5 changed files with 9 additions and 8 deletions

View File

@@ -76,7 +76,7 @@ class CompilerTools {
var classPathFolders = classPath.split("/"); var classPathFolders = classPath.split("/");
while (classPathFolders.length > 0) { while (classPathFolders.length > 0) {
try { try {
Helpers.libPath(classPathFolders[classPathFolders.length - 1]); Prelude.libPath(classPathFolders[classPathFolders.length - 1]);
break; break;
} catch (e) { } catch (e) {
classPathFolders.pop(); classPathFolders.pop();
@@ -116,7 +116,7 @@ class CompilerTools {
mainHxFile = args.mainHxFile; mainHxFile = args.mainHxFile;
copyToFolder(mainHxFile); copyToFolder(mainHxFile);
} else { } else {
copyToFolder(mainHxFile, Path.join([Helpers.libPath("kiss"), "src", "kiss"])); copyToFolder(mainHxFile, Path.join([Prelude.libPath("kiss"), "src", "kiss"]));
} }
var mainClassName = mainHxFile.withoutDirectory().withoutExtension(); var mainClassName = mainHxFile.withoutDirectory().withoutExtension();

View File

@@ -561,9 +561,4 @@ class Helpers {
throw CompileError.fromExp(exp, '$forThis bindings should be a list expression with an even number of sub expressions (at least 2)'); throw CompileError.fromExp(exp, '$forThis bindings should be a list expression with an even number of sub expressions (at least 2)');
}; };
} }
// Get the path to a haxelib the user has installed
public static function libPath(haxelibName:String) {
return Prelude.assertProcess("haxelib", ["libpath", haxelibName]).trim();
}
} }

View File

@@ -76,6 +76,7 @@ class Kiss {
"count" => Symbol("Lambda.count"), "count" => Symbol("Lambda.count"),
"enumerate" => Symbol("Prelude.enumerate"), "enumerate" => Symbol("Prelude.enumerate"),
"assertProcess" => Symbol("Prelude.assertProcess"), "assertProcess" => Symbol("Prelude.assertProcess"),
"libPath" => Symbol("Prelude.libPath"),
"random" => Symbol("Std.random"), "random" => Symbol("Std.random"),
"walkDirectory" => Symbol("Prelude.walkDirectory"), "walkDirectory" => Symbol("Prelude.walkDirectory"),
"purgeDirectory" => Symbol("Prelude.purgeDirectory"), "purgeDirectory" => Symbol("Prelude.purgeDirectory"),

View File

@@ -49,7 +49,7 @@ class Macros {
var libPath = switch (args[0].def) { var libPath = switch (args[0].def) {
case StrExp(libName): case StrExp(libName):
Helpers.libPath(libName); Prelude.libPath(libName);
default: default:
throw CompileError.fromExp(args[0], "first argument to loadFrom should be a string literal of a haxe library's name"); throw CompileError.fromExp(args[0], "first argument to loadFrom should be a string literal of a haxe library's name");
}; };

View File

@@ -581,6 +581,11 @@ class Prelude {
#end #end
} }
// Get the path to a haxelib the user has installed
public static function libPath(haxelibName:String) {
return assertProcess("haxelib", ["libpath", haxelibName]).trim();
}
public static function filter<T>(l:Iterable<T>, ?p:(T) -> Bool):kiss.List<T> { public static function filter<T>(l:Iterable<T>, ?p:(T) -> Bool):kiss.List<T> {
if (p == null) if (p == null)
p = Prelude.truthy; p = Prelude.truthy;