make libPath part of Prelude

This commit is contained in:
2021-10-22 16:26:19 -04:00
parent 00759253d0
commit 13fd64c2f5
7 changed files with 11 additions and 9 deletions

View File

@@ -76,7 +76,7 @@ class CompilerTools {
var classPathFolders = classPath.split("/");
while (classPathFolders.length > 0) {
try {
Helpers.libPath(classPathFolders[classPathFolders.length - 1]);
Prelude.libPath(classPathFolders[classPathFolders.length - 1]);
break;
} catch (e) {
classPathFolders.pop();
@@ -116,7 +116,7 @@ class CompilerTools {
mainHxFile = args.mainHxFile;
copyToFolder(mainHxFile);
} else {
copyToFolder(mainHxFile, Path.join([Helpers.libPath("kiss"), "src", "kiss"]));
copyToFolder(mainHxFile, Path.join([Prelude.libPath("kiss"), "src", "kiss"]));
}
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)');
};
}
// 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"),
"enumerate" => Symbol("Prelude.enumerate"),
"assertProcess" => Symbol("Prelude.assertProcess"),
"libPath" => Symbol("Prelude.libPath"),
"random" => Symbol("Std.random"),
"walkDirectory" => Symbol("Prelude.walkDirectory"),
"purgeDirectory" => Symbol("Prelude.purgeDirectory"),

View File

@@ -49,7 +49,7 @@ class Macros {
var libPath = switch (args[0].def) {
case StrExp(libName):
Helpers.libPath(libName);
Prelude.libPath(libName);
default:
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
}
// 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> {
if (p == null)
p = Prelude.truthy;

View File

@@ -12,7 +12,6 @@
(var &mut :KissConfig config null)
(function :Void tryLoadConfig [&opt :String text]
// TODO if a config object is active and a shortcut panel is open, dispose the panel before we lose the handle in the current config object
(let [handleConfigFailure
->errorMessage {
(FileSystem.deleteDirectory activeConfigDir)

View File

@@ -5,6 +5,8 @@
options ,options
result (ChildProcess.spawnSync command args options)]
(if result.error
// TODO i can't remember if this needs to be a throw for some reason,
// but it seems like it's supposed to be (,onError ...)(return) like below
(throw "Error $result.error from $command ${args}: $result.stdout $result.stderr")
(case result.status
(0 null)