2022-02-14 15:06:08 +01:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
|
|
|
|
|
namespace GitHub.Runner.Common.Util
|
|
|
|
|
{
|
|
|
|
|
public static class NodeUtil
|
|
|
|
|
{
|
|
|
|
|
private const string _defaultNodeVersion = "node16";
|
2022-05-20 11:00:54 -04:00
|
|
|
|
2022-09-26 09:20:43 -04:00
|
|
|
#if (OS_OSX || OS_WINDOWS) && ARM64
|
2022-05-20 11:00:54 -04:00
|
|
|
public static readonly ReadOnlyCollection<string> BuiltInNodeVersions = new(new[] { "node16" });
|
|
|
|
|
#else
|
|
|
|
|
public static readonly ReadOnlyCollection<string> BuiltInNodeVersions = new(new[] { "node12", "node16" });
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-02-25 20:59:02 +01:00
|
|
|
public static string GetInternalNodeVersion()
|
2022-02-14 15:06:08 +01:00
|
|
|
{
|
2022-06-22 17:13:28 +02:00
|
|
|
var forcedInternalNodeVersion = Environment.GetEnvironmentVariable(Constants.Variables.Agent.ForcedInternalNodeVersion);
|
|
|
|
|
var isForcedInternalNodeVersion = !string.IsNullOrEmpty(forcedInternalNodeVersion) && BuiltInNodeVersions.Contains(forcedInternalNodeVersion);
|
|
|
|
|
|
|
|
|
|
if (isForcedInternalNodeVersion)
|
|
|
|
|
{
|
|
|
|
|
return forcedInternalNodeVersion;
|
|
|
|
|
}
|
|
|
|
|
return _defaultNodeVersion;
|
2022-02-14 15:06:08 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|