Skip to content

Commit

Permalink
Fix #1247 - Maven build use node from PATH on mac os
Browse files Browse the repository at this point in the history
  • Loading branch information
zulus committed Sep 24, 2023
1 parent bd4d902 commit 45e0f87
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="org.eclipse.wildwebdeveloper.embedder.node.feature"
label="%name"
version="1.0.6.qualifier"
version="1.0.7.qualifier"
provider-name="Eclipse Wild Web Developer project"
license-feature="org.eclipse.license"
license-feature-version="0.0.0">
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.wildwebdeveloper.embedder.node.feature/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<version>1.0.0-SNAPSHOT</version>
</parent>
<packaging>eclipse-feature</packaging>
<version>1.0.6-SNAPSHOT</version>
<version>1.0.7-SNAPSHOT</version>
<build>
<plugins>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Manager for embedded Node.js
Bundle-SymbolicName: org.eclipse.wildwebdeveloper.embedder.node
Bundle-Version: 1.0.2.qualifier
Bundle-Version: 1.0.3.qualifier
Bundle-Vendor: Eclipse Wild Web Developer
Automatic-Module-Name: org.eclipse.wildwebdeveloper.embedder.node
Bundle-RequiredExecutionEnvironment: JavaSE-17
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.wildwebdeveloper.embedder.node/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<version>1.0.0-SNAPSHOT</version>
</parent>
<packaging>eclipse-plugin</packaging>
<version>1.0.2-SNAPSHOT</version>
<version>1.0.3-SNAPSHOT</version>

<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;

import org.eclipse.core.internal.runtime.InternalPlatform;
Expand Down Expand Up @@ -117,12 +120,40 @@ public static File getNpmLocation() {
File nodeJsLocation = getNodeJsLocation();
if (nodeJsLocation != null) {
File res = new File(nodeJsLocation.getParentFile(), npmFileName);
if (res.canExecute()) {
if (res.exists()) {
return res;
}
}
return which(npmFileName);
}

public static ProcessBuilder prepareNodeProcessBuilder(String... commands)
{
return prepareNodeProcessBuilder(Arrays.asList(commands));
}

public static ProcessBuilder prepareNodeProcessBuilder(List<String> commands)
{
List<String> tmp = new ArrayList<>();
tmp.add(getNodeJsLocation().getAbsolutePath());
tmp.addAll(commands);

return new ProcessBuilder(tmp);
}

public static ProcessBuilder prepareNPMProcessBuilder(String... commands)
{
return prepareNPMProcessBuilder(Arrays.asList(commands));
}

public static ProcessBuilder prepareNPMProcessBuilder(List<String> commands)
{
List<String> tmp = new ArrayList<>();
tmp.add(getNpmLocation().getAbsolutePath());
tmp.addAll(commands);

return prepareNodeProcessBuilder(tmp);
}

public static File which(String program) {
Properties properties = getNodeJsInfoProperties();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public static void setUp() throws Exception {
AllCleanRule.enableLogging();

project = Utils.provisionTestProject("angular-app");
ProcessBuilder builder = new ProcessBuilder(NodeJSManager.getNpmLocation().getAbsolutePath(), "install",
"--no-bin-links", "--ignore-scripts").directory(project.getLocation().toFile());
ProcessBuilder builder = NodeJSManager.prepareNPMProcessBuilder("install", "--no-bin-links", "--ignore-scripts")
.directory(project.getLocation().toFile());
Process process = builder.start();
System.out.println(builder.command().toString());
String result = new BufferedReader(new InputStreamReader(process.getErrorStream())).lines()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ public static void setUpProject() throws Exception {
try (InputStream eslintRc = TestESLint.class.getResourceAsStream("/testProjects/eslint/ESLintProj.js")) {
Files.copy(eslintRc, new File(projectDirectory, "ESLintProj.tsx").toPath());
}
ProcessBuilder builder = new ProcessBuilder(NodeJSManager.getNpmLocation().getAbsolutePath(), "install",
"--no-bin-links", "--ignore-scripts").directory(projectDirectory);
ProcessBuilder builder = NodeJSManager.prepareNPMProcessBuilder("install", "--no-bin-links", "--ignore-scripts")
.directory(projectDirectory);
Process dependencyInstaller = builder.start();
System.out.println(builder.command().toString());
String result = new BufferedReader(new InputStreamReader(dependencyInstaller.getErrorStream())).lines()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public static void setUp() throws Exception {
AllCleanRule.enableLogging();

project = Utils.provisionTestProject("vue-app");
ProcessBuilder builder = new ProcessBuilder(NodeJSManager.getNpmLocation().getAbsolutePath(), "install",
"--no-bin-links", "--ignore-scripts").directory(project.getLocation().toFile());
ProcessBuilder builder = NodeJSManager.prepareNPMProcessBuilder("install", "--no-bin-links", "--ignore-scripts")
.directory(project.getLocation().toFile());
Process process = builder.start();
System.out.println(builder.command().toString());
String result = new BufferedReader(new InputStreamReader(process.getErrorStream())).lines()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void launch(ILaunchConfiguration configuration, String mode, ILaunch laun
final String argumentString = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(configuration.getAttribute(ARGUMENTS, "No NPM argument set") //$NON-NLS-1$
.trim());
List<String> arguments = new ArrayList<>();
arguments.add(NodeJSManager.getNpmLocation().getAbsolutePath());
arguments.addAll(NodeJSManager.prepareNPMProcessBuilder().command());
arguments.addAll(Arrays.asList(argumentString.split(" "))); //$NON-NLS-1$
monitor.beginTask(argumentString + ' ' + packageJSON.getAbsolutePath(), 2);
monitor.worked(1);
Expand Down

0 comments on commit 45e0f87

Please sign in to comment.