Add support for macOS
elliott-miller opened this issue · 3 comments
elliott-miller commented
PowerShellExecutor.instance
creates an UnsupportedOsPowerShellExecutor
on MacOS. The LinuxPowerShellExecutor
works fine on macOS assuming Powershell is installed. See the following hack:
public static void main(String[] args)
throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
var c = Class.forName("com.github.frimtec.libraries.jpse.LinuxPowerShellExecutor");
var constructor = c.getDeclaredConstructor(Path.class);
constructor.setAccessible(true);
var executor = (PowerShellExecutor) constructor.newInstance((Path) null);
System.out.println("PowerShell runtime version " +
executor.version()
.orElseThrow(() -> new RuntimeException("No PowerShell runtime available")));
System.out.println(executor.execute("Write-Host Hello PowerShell!").getStandardOutput());
}
Outputs
PowerShell runtime version 7.3
Hello PowerShell!
frimtec commented
Hi @elliott-miller
Can you do me a favour and let me know what System.getProperty("os.name")
returns on MacOS.
I have no MacOS at hand ;-)
I will then prepare a fix.
frimtec commented
Should be fixed with release 1.3.3.
Would be great to get your feedback @elliott-miller, as I can't test it.
elliott-miller commented
In answer to your earlier question....
System.out.println(System.getProperty("os.name"));
Prints
Mac OS X
I have tried 1.3.3 and can confirm it works, many thanks!