Skip to content

Commit

Permalink
Add -npx flag for lime test electron to run the npx electron comm…
Browse files Browse the repository at this point in the history
…and instead of just `electron`.

This will prompt the user to install electron, if required. Saves a separate `npm install -g electron` command before testing.
  • Loading branch information
joshtynjala committed Jul 25, 2023
1 parent 2cd1dad commit 6cff640
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/lime/tools/ElectronHelper.hx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ import lime.tools.HXProject;

class ElectronHelper
{
public static function launch(project:HXProject, path:String):Void
public static function launch(project:HXProject, path:String, ?npx:Bool):Void
{
var electronPath = project.defines.get("ELECTRON_PATH");
if (npx)
{
System.runCommand("", "npx", ["electron", path]);
return;
}

var electronPath = project.defines.get("ELECTRON_PATH");
if (electronPath == null || electronPath == "")
{
electronPath = "electron";
Expand Down
3 changes: 2 additions & 1 deletion tools/platforms/HTML5Platform.hx
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ class HTML5Platform extends PlatformTarget
}
else if (targetFlags.exists("electron"))
{
ElectronHelper.launch(project, targetDirectory + "/bin");
var npx = targetFlags.exists("npx");
ElectronHelper.launch(project, targetDirectory + "/bin", npx);
}
else
{
Expand Down

0 comments on commit 6cff640

Please sign in to comment.