Skip to content

Commit

Permalink
allow -D frontend for cases where hxnodejs is accidentally included
Browse files Browse the repository at this point in the history
  • Loading branch information
NQNStudios committed Nov 30, 2024
1 parent 2212149 commit 6ed66d8
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/kiss/Prelude.hx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import haxe.DynamicAccess;
#if js
import js.lib.Promise;
#end
#if (!macro && hxnodejs)
#if (!macro && hxnodejs && !frontend)
import js.node.ChildProcess;
import js.node.Buffer;
#elseif sys
import sys.io.Process;
#end
#if (sys || hxnodejs)
#if ((sys || hxnodejs) && !frontend)
import sys.FileSystem;
import sys.io.File;
#end
Expand Down Expand Up @@ -477,7 +477,7 @@ class Prelude {
} else {
var ret = Reflect.callMethod(caller, func, args);
argMap[argString] = ret;
#if (sys || hxnodejs)
#if ((sys || hxnodejs) && !frontend)
if (jsonFile != null) {
File.saveContent(jsonFile, Json.stringify(argMap));
}
Expand All @@ -489,7 +489,7 @@ class Prelude {
return f;
}

#if (sys || hxnodejs)
#if ((sys || hxnodejs) && !frontend)
public static function fsMemoize(func:Function, funcName:String, cacheDirectory = "", ?caller:Dynamic):Function {
var fileName = '${funcName}.memoized';
if (cacheDirectory.length > 0) {
Expand All @@ -506,7 +506,7 @@ class Prelude {
#end

public static function _printStr(s:String) {
#if (sys || hxnodejs)
#if ((sys || nodejs) && !frontend)
Sys.println(s);
#else
trace(s);
Expand Down Expand Up @@ -614,7 +614,7 @@ class Prelude {

public static function walkDirectory(basePath, directory, processFile:(String) -> Void, ?filterFolderBefore:(String) -> Bool,
?processFolderAfter:(String) -> Void) {
#if (sys || hxnodejs)
#if ((sys || hxnodejs) && !frontend)
for (fileOrFolder in FileSystem.readDirectory(joinPath(basePath, directory))) {
switch (fileOrFolder) {
case folder if (FileSystem.isDirectory(joinPath(basePath, directory, folder))):
Expand All @@ -638,7 +638,7 @@ class Prelude {
}

public static function purgeDirectory(directory) {
#if (sys || hxnodejs)
#if ((sys || hxnodejs) && !frontend)
walkDirectory("", directory, FileSystem.deleteFile, null, FileSystem.deleteDirectory);
FileSystem.deleteDirectory(directory);
#else
Expand All @@ -656,7 +656,7 @@ class Prelude {
public static function convertToHScript(kissStr:String):String {
var unsupportedMessage = "Can't convert Kiss to HScript on this target.";

#if (!sys && !hxnodejs)
#if ((!sys && !hxnodejs) || frontend)
throw unsupportedMessage;
#else

Expand All @@ -675,7 +675,7 @@ class Prelude {
#if macro
return Kiss.measure("Prelude.convertToHScript", () -> {
#end
#if (!macro && hxnodejs)
#if (!macro && hxnodejs && !frontend)
var hscript = try {
assertProcess("haxe", [buildHxml, "convert", "--all", "--hscript"], kissStr.split('\n'), true, cwd);
} catch (e) {
Expand Down Expand Up @@ -725,7 +725,7 @@ class Prelude {
#end
}

#if (sys || hxnodejs)
#if ((sys || hxnodejs) && !frontend)
public static function userHome() {
var msysHome = Sys.getEnv("MSYSHOME");
var home = Sys.getEnv("HOME");
Expand All @@ -750,7 +750,7 @@ class Prelude {
CSharp;
#elseif interp
Haxe;
#elseif hxnodejs
#elseif (hxnodejs && !frontend)
NodeJS;
#elseif js
JavaScript;
Expand Down Expand Up @@ -852,7 +852,7 @@ class Prelude {
handleError('process $command $args failed: $e');
return null;
}
#elseif hxnodejs
#elseif (hxnodejs && !frontend)
var p = if (inputLines != null) {
ChildProcess.spawnSync(command, args, {input: inputLines.join("\n"), cwd: cwd});
} else {
Expand Down Expand Up @@ -885,7 +885,7 @@ class Prelude {
static var shellCount = 0;

public static function shellExecute(script:String, shell:String) {
#if (sys || hxnodejs)
#if ((sys || hxnodejs) && !frontend)
if (shell.length == 0) {
shell = if (Sys.systemName() == "Windows") "cmd /c" else "bash";
}
Expand Down Expand Up @@ -924,7 +924,7 @@ class Prelude {
return Lambda.filter(l, p);
}

#if (sys || hxnodejs)
#if ((sys || hxnodejs) && !frontend)
public static function readDirectory(dir:String) {
return [for (file in FileSystem.readDirectory(dir)) {
joinPath(dir, file);
Expand Down

0 comments on commit 6ed66d8

Please sign in to comment.