findNodeForTests function
A Node ≥ requiredNodeMajorVersion, or null when the machine has none.
node on PATH is often an older default, so an nvm install is consulted
before giving up: the point is to run the real server on every machine that
can run it, not to make a developer re-shim their shell first.
Implementation
String? findNodeForTests() {
final candidates = <String>[
if (Platform.environment[agentSdkNodeEnvVar] case final n?
when n.isNotEmpty)
n,
'node',
..._nvmCandidates(),
];
for (final candidate in candidates) {
if (_majorVersionOf(candidate) case final major?
when major >= requiredNodeMajorVersion) {
return candidate;
}
}
return null;
}