/// <nodoc/> public JavaScriptGraphConstructionFailure(IProjectGraphResolverSettings settings, PathTable pathTable) { Contract.Requires(settings != null); Contract.Requires(pathTable != null); m_settings = settings; m_pathTable = pathTable; }
/// <summary> /// Process <see cref="IProjectGraphResolverSettings.Environment"/> and split the specified environment variables that need to be exposed and tracked from the passthrough environment variables /// </summary> /// <remarks> /// When <see cref="IProjectGraphResolverSettings.Environment"/> is null, the current environment is defined as the tracked environment, with no passthroughs /// </remarks> public static void ComputeEnvironment(this IProjectGraphResolverSettings rushResolverSettings, PathTable pathTable, out IDictionary <string, string> trackedEnv, out ICollection <string> passthroughEnv, out bool processEnvironmentUsed) { if (rushResolverSettings.Environment == null) { var allEnvironmentVariables = Environment.GetEnvironmentVariables(); processEnvironmentUsed = true; trackedEnv = new Dictionary <string, string>(allEnvironmentVariables.Count, OperatingSystemHelper.EnvVarComparer); foreach (var envVar in allEnvironmentVariables.Keys) { object value = allEnvironmentVariables[envVar]; trackedEnv[envVar.ToString()] = value.ToString(); } passthroughEnv = CollectionUtilities.EmptyArray <string>(); return; } processEnvironmentUsed = false; var trackedList = new Dictionary <string, string>(OperatingSystemHelper.EnvVarComparer); var passthroughList = new List <string>(); foreach (var kvp in rushResolverSettings.Environment) { var valueOrPassthrough = kvp.Value?.GetValue(); if (valueOrPassthrough == null || !(valueOrPassthrough is UnitValue)) { trackedList.Add(kvp.Key, ProcessEnvironmentData(kvp.Value, pathTable)); } else { passthroughList.Add(kvp.Key); } } trackedEnv = trackedList; passthroughEnv = passthroughList; }