From 571c2bd181e7e88c5380d0e42a8b4886dec28cbf Mon Sep 17 00:00:00 2001 From: Josh Tynjala Date: Tue, 16 May 2023 12:50:53 -0700 Subject: [PATCH] HTML5Helper, similar to -terser, adding -npx for Closure Compiler also uses the npx version instead of the bundled version --- src/lime/tools/HTML5Helper.hx | 43 +++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/src/lime/tools/HTML5Helper.hx b/src/lime/tools/HTML5Helper.hx index cc4c2e793..0adb17ba1 100644 --- a/src/lime/tools/HTML5Helper.hx +++ b/src/lime/tools/HTML5Helper.hx @@ -229,20 +229,33 @@ class HTML5Helper } else { - var templatePaths = [ - Path.combine(Haxelib.getPath(new Haxelib(#if lime "lime" #else "hxp" #end)), #if lime "templates" #else "" #end) - ].concat(project.templatePaths); - var args = [ - "-Dapple.awt.UIElement=true", - "-jar", - System.findTemplate(templatePaths, "bin/compiler.jar"), - "--strict_mode_input", - "false", - "--js", - sourceFile, - "--js_output_file", - tempFile - ]; + var executable:String; + var args:Array; + if (project.targetFlags.exists("npx")) + { + executable = "npx"; + args = [ + "google-closure-compiler" + ]; + } + else + { + executable = "java"; + var templatePaths = [ + Path.combine(Haxelib.getPath(new Haxelib(#if lime "lime" #else "hxp" #end)), #if lime "templates" #else "" #end) + ].concat(project.templatePaths); + args = [ + "-Dapple.awt.UIElement=true", + "-jar", + System.findTemplate(templatePaths, "bin/compiler.jar"), + ]; + } + args.push("--strict_mode_input"); + args.push("false"); + args.push("--js"); + args.push(sourceFile); + args.push("--js_output_file"); + args.push(tempFile); if (project.targetFlags.exists("advanced")) { @@ -267,7 +280,7 @@ class HTML5Helper args.push("--jscomp_off=suspiciousCode"); // avoid warnings caused by the embedded minified libraries } - System.runCommand("", "java", args); + System.runCommand("", executable, args); if (FileSystem.exists(tempFile + ".map")) {