Skip to content

Commit 8ab686a

Browse files
committed
NodeJSManager wrongly claims Node 16 is not supported
And we shipt Node.js 16.x as our bundled. The idea of static list of supported versions is plain wrong as we have no idea which editor which version of Node.js supports it's best to remove the static list and just say "recent" version is required when using the "system" Node.
1 parent 206c9fa commit 8ab686a

File tree

1 file changed

+13
-40
lines changed
  • org.eclipse.wildwebdeveloper.embedder.node/src/org/eclipse/wildwebdeveloper/embedder/node

1 file changed

+13
-40
lines changed

org.eclipse.wildwebdeveloper.embedder.node/src/org/eclipse/wildwebdeveloper/embedder/node/NodeJSManager.java

Lines changed: 13 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2019, 2021 Red Hat Inc. and others.
2+
* Copyright (c) 2019, 2022 Red Hat Inc. and others.
33
*
44
* This program and the accompanying materials are made
55
* available under the terms of the Eclipse Public License 2.0
@@ -23,8 +23,6 @@
2323
import java.io.InputStreamReader;
2424
import java.net.URL;
2525
import java.util.Properties;
26-
import java.util.Set;
27-
import java.util.stream.Collectors;
2826

2927
import org.eclipse.core.internal.runtime.InternalPlatform;
3028
import org.eclipse.core.runtime.FileLocator;
@@ -35,28 +33,23 @@
3533
import org.eclipse.core.runtime.Status;
3634
import org.eclipse.jface.dialogs.MessageDialog;
3735
import org.eclipse.swt.widgets.Display;
38-
import org.osgi.framework.Version;
3936

4037
@SuppressWarnings("restriction")
4138
public class NodeJSManager {
4239

4340
private static final String MACOS_DSCL_SHELL_PREFIX = "UserShell: ";
4441

45-
private static final Set<Integer> SUPPORT_NODEJS_MAJOR_VERSIONS = Set.of(10, 11, 12, 13, 14);
46-
4742
private static boolean alreadyWarned;
4843
private static Properties cachedNodeJsInfoProperties;
4944
private static final Object EXPAND_LOCK = new Object();
5045

5146
public static File getNodeJsLocation() {
52-
{
53-
String nodeJsLocation = System.getProperty("org.eclipse.wildwebdeveloper.nodeJSLocation");
54-
if (nodeJsLocation != null) {
55-
File nodejs = new File(nodeJsLocation);
56-
if (nodejs.exists()) {
57-
validateNodeVersion(nodejs);
58-
return new File(nodeJsLocation);
59-
}
47+
String nodeJsLocation = System.getProperty("org.eclipse.wildwebdeveloper.nodeJSLocation");
48+
if (nodeJsLocation != null) {
49+
File nodejs = new File(nodeJsLocation);
50+
if (nodejs.exists()) {
51+
validateNodeVersion(nodejs);
52+
return new File(nodeJsLocation);
6053
}
6154
}
6255

@@ -177,7 +170,7 @@ private static Properties getNodeJsInfoProperties() {
177170

178171
private static String getDefaultShellMacOS() {
179172
String res = null;
180-
String[] command = new String[] { "/bin/bash", "-c", "-l", "dscl . -read ~/ UserShell" };
173+
String[] command = { "/bin/bash", "-c", "-l", "dscl . -read ~/ UserShell" };
181174
try (BufferedReader reader = new BufferedReader(
182175
new InputStreamReader(Runtime.getRuntime().exec(command).getInputStream()));) {
183176
res = reader.readLine();
@@ -197,15 +190,15 @@ private static String getDefaultShellMacOS() {
197190

198191
private static File getDefaultNodePath() {
199192
return new File(switch (Platform.getOS()) {
200-
case Platform.OS_MACOSX -> "/usr/local/bin/node";
201-
case Platform.OS_WIN32 -> "C:\\Program Files\\nodejs\\node.exe";
202-
default ->"/usr/bin/node";
193+
case Platform.OS_MACOSX -> "/usr/local/bin/node";
194+
case Platform.OS_WIN32 -> "C:\\Program Files\\nodejs\\node.exe";
195+
default -> "/usr/bin/node";
203196
});
204197
}
205198

206199
private static void validateNodeVersion(File nodeJsLocation) {
207200
String nodeVersion = null;
208-
String[] nodeVersionCommand = new String[] { nodeJsLocation.getAbsolutePath(), "-v" };
201+
String[] nodeVersionCommand = { nodeJsLocation.getAbsolutePath(), "-v" };
209202

210203
try (BufferedReader reader = new BufferedReader(
211204
new InputStreamReader(Runtime.getRuntime().exec(nodeVersionCommand).getInputStream()));) {
@@ -217,12 +210,6 @@ private static void validateNodeVersion(File nodeJsLocation) {
217210

218211
if (nodeVersion == null) {
219212
warnNodeJSVersionCouldNotBeDetermined();
220-
} else {
221-
Version parsedVersion = Version
222-
.parseVersion(nodeVersion.startsWith("v") ? nodeVersion.replace("v", "") : nodeVersion);
223-
if (!SUPPORT_NODEJS_MAJOR_VERSIONS.contains(parsedVersion.getMajor())) {
224-
warnNodeJSVersionUnsupported(nodeVersion);
225-
}
226213
}
227214
}
228215

@@ -235,25 +222,11 @@ private static void warnNodeJSMissing() {
235222
alreadyWarned = true;
236223
}
237224

238-
private static void warnNodeJSVersionUnsupported(String version) {
239-
if (!alreadyWarned) {
240-
Display.getDefault().asyncExec(() -> MessageDialog.openWarning(Display.getCurrent().getActiveShell(),
241-
"Node.js " + version + " is not supported",
242-
"Node.js " + version + " is not supported. This will result in editors missing key features.\n"
243-
+ "Please make sure a supported version of node.js is installed and that your PATH environment variable contains the location to the `node` executable.\n"
244-
+ "Supported major versions are: " + SUPPORT_NODEJS_MAJOR_VERSIONS.stream()
245-
.map(String::valueOf).collect(Collectors.joining(", "))));
246-
}
247-
alreadyWarned = true;
248-
}
249-
250225
private static void warnNodeJSVersionCouldNotBeDetermined() {
251226
if (!alreadyWarned) {
252227
Display.getDefault().asyncExec(() -> MessageDialog.openWarning(Display.getCurrent().getActiveShell(),
253228
"Node.js version could not be determined",
254-
"Node.js version could not be determined. Please make sure a supported version of node.js is installed, editors may be missing key features otherwise.\n"
255-
+ "Supported major versions are: " + SUPPORT_NODEJS_MAJOR_VERSIONS.stream()
256-
.map(String::valueOf).collect(Collectors.joining(", "))));
229+
"Node.js version could not be determined. Please make sure a recent version of node.js is installed, editors may be missing key features otherwise.\n"));
257230
}
258231
alreadyWarned = true;
259232
}

0 commit comments

Comments
 (0)