diff --git a/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/NodeInstaller.java b/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/NodeInstaller.java index 3e0173b01..3d33c1cf0 100644 --- a/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/NodeInstaller.java +++ b/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/NodeInstaller.java @@ -92,7 +92,7 @@ public void install() throws InstallationException { versionManagerRunner.installNodeAndUpdateCaches(); return; } else { - this.logger.warn("Node version manager is no available, falling back to standard node installation."); + this.logger.warn("Node version manager is not available, falling back to standard node installation."); } // try to install the standard way diff --git a/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/Platform.java b/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/Platform.java index 64d088baa..39c4c6864 100644 --- a/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/Platform.java +++ b/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/Platform.java @@ -66,7 +66,7 @@ public String getCodename(){ } } -class Platform { +public class Platform { /** * Node.js supports Apple silicon since v16 diff --git a/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/version/manager/ShellExecutor.java b/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/version/manager/ShellExecutor.java index bb8c50902..89873184f 100644 --- a/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/version/manager/ShellExecutor.java +++ b/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/version/manager/ShellExecutor.java @@ -29,14 +29,14 @@ public String executeAndCatchErrors(List command) { try { int exitValue = execute(profiledShellCommand, stdout, stderr); if (exitValue != 0) { - logger.debug("Command finished with error exit code {}, error output `{}`", exitValue, parseOutput(stderr)); + logger.debug("Command finished with an error exit code {}", exitValue); } } catch (ProcessExecutionException e) { - logger.debug("Command threw unexpectedly, error output: `{}`", parseOutput(stderr)); + logger.debug("Command threw unexpectedly"); } String output = parseOutput(stdout); - logger.debug("Command output: `{}`", output); + logger.debug("Command output: `{}`\n error output `{}`", output, parseOutput(stderr)); return output; } @@ -80,10 +80,16 @@ private int execute(List command, ByteArrayOutputStream stdout, ByteArra private List getShellCommand(List command) { List profiledShellCommand = new ArrayList<>(); - profiledShellCommand.add(getCurrentShell()); - profiledShellCommand.add("--login"); - profiledShellCommand.add("-c"); - profiledShellCommand.add(String.join(" ", command)); + + if (config.getPlatform().isWindows()) { + logger.warn("Windows is currently not supported"); + profiledShellCommand.add(String.join(" ", command)); + } else { + profiledShellCommand.add(getCurrentUnixShell()); + profiledShellCommand.add("--login"); + profiledShellCommand.add("-c"); + profiledShellCommand.add(String.join(" ", command)); + } return profiledShellCommand; } @@ -92,21 +98,21 @@ private String parseOutput(ByteArrayOutputStream stream) { return stream.toString().trim(); } - private String getCurrentShell() { + private String getCurrentUnixShell() { String shell = System.getenv("SHELL"); if (shell == null || shell.isEmpty()) { - logger.debug("SHELL is not available in environment variables. Trying to get it from child process."); - + logger.debug("SHELL variable couldn't be found. Falling back on reading the variable from /bin/sh."); ByteArrayOutputStream stdout = new ByteArrayOutputStream(); try { - execute(Arrays.asList("echo", "$SHELL"), stdout, stdout); + execute(Arrays.asList("/bin/sh", "-c", "echo $SHELL"), stdout, stdout); shell = parseOutput(stdout); + logger.debug("SHELL from /bin/sh: {}", shell); } catch (ProcessExecutionException e) { throw new RuntimeException(e); } if (shell.isEmpty()) { - throw new RuntimeException("SHELL was not available in child process. Falling back to bin/sh"); + throw new RuntimeException("SHELL is not available in environment variables. Please provide the value of $SHELL with your preferred shell."); } } diff --git a/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/version/manager/VersionManagerRunner.java b/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/version/manager/VersionManagerRunner.java index 4e4879cab..29850d951 100644 --- a/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/version/manager/VersionManagerRunner.java +++ b/frontend-plugin-core/src/main/java/com/github/eirslett/maven/plugins/frontend/lib/version/manager/VersionManagerRunner.java @@ -30,7 +30,7 @@ public VersionManagerRunner(InstallConfig installConfig, VersionManagerCache ver public void installNodeAndUpdateCaches() { if (!installConfig.isUseNodeVersionManager()) return; - logger.info("Installing node with {}", versionManagerCache.getVersionManagerType()); + logger.info("Installing node with {}. (Relying on node version manager caching)", versionManagerCache.getVersionManagerType()); versionManagerClient.installNode(); populateCache();