Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added haxelib run pickhaxe setup Support on MacOS #34

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/net/pickhaxe/tools/commands/Setup.hx
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,18 @@ class Setup implements ICommand

function setupMac():Void
{
// TODO: Implement this.
// https://github.com/openfl/lime/blob/develop/tools/utils/PlatformSetup.hx#L824
CLI.print('Sorry, this command is not supported on your platform.');
var haxePathEnv:String = Sys.getEnv('HAXEPATH') ?? '/usr/local/bin';
var haxePath:Path = new Path(haxePathEnv);

try
{
var source:Path = IO.libraryDir().joinPaths('templates/bin/${Constants.LIBRARY_ID}.sh');
var target:Path = haxePath.joinPaths('${Constants.LIBRARY_ID}');

IO.copyFileUnix(source, target);
IO.updatePermissions(target);
}
catch (e:Dynamic) {}
}

function setupLinux():Void
Expand Down
20 changes: 20 additions & 0 deletions src/net/pickhaxe/tools/util/IO.hx
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,26 @@ class IO
sys.io.File.copy(source.toString(), dest.toString());
}

/**
* Copy a file from one location to another
* , requesting administrative access.
* @param source The path to the file to copy.
* @param dest The path to copy the file to.
*/
public static function copyFileUnix(source:Path, dest:Path):Void
{
Sys.command("sudo", ["cp", source.toString(), dest.toString()]);
}

/*
* Update permissions for file to not require administration access. (Unix only)
* @param path The path to the file to update permissions for.
*/
public static function updatePermissions(path:Path):Void
{
Sys.command("sudo", ["chmod", "+x", path.toString()]);
}

/**
* Clean up a path and convert it to a Path object.
* @param input The path to clean up.
Expand Down