Skip to content

Commit 6e30cb2

Browse files
author
Ellis Kenyo
committed
Better way of merging dictionaries
1 parent eff333d commit 6e30cb2

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/Middleware/SpaServices.Extensions/src/DevelopmentServer/DevelopmentServerMiddleware.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System;
1010
using System.IO;
1111
using System.Collections.Generic;
12+
using System.Linq;
1213
using System.Text.RegularExpressions;
1314
using System.Threading.Tasks;
1415
using Microsoft.AspNetCore.SpaServices.Extensions.Util;
@@ -63,7 +64,7 @@ public static void Attach(
6364
}
6465

6566
private static async Task<int> StartDevServerAsync(
66-
string sourcePath, string npmScriptName, string waitText, string serverName, ILogger logger, IDictionary<string, string> extraArgs)
67+
string sourcePath, string npmScriptName, string waitText, string serverName, ILogger logger, Dictionary<string, string> extraArgs = null)
6768
{
6869
var portNumber = TcpPortFinder.FindAvailablePort();
6970
logger.LogInformation($"Starting {serverName} server on port {portNumber}...");
@@ -72,8 +73,17 @@ private static async Task<int> StartDevServerAsync(
7273
{
7374
{ "PORT", portNumber.ToString() }
7475
};
76+
if (extraArgs == null)
77+
{
78+
extraArgs = new Dictionary<string, string>
79+
{
80+
{ "BROWSER", "None" }
81+
};
82+
}
83+
var extraKeys = new HashSet<string>(extraArgs.Keys);
84+
extraKeys.UnionWith(envVars.Keys);
7585
var npmScriptRunner = new NpmScriptRunner(
76-
sourcePath, npmScriptName, null, envVars.Union(extraArgs));
86+
sourcePath, npmScriptName, null, envVars);
7787
npmScriptRunner.AttachToLogger(logger);
7888

7989
using (var stdErrReader = new EventedStreamStringReader(npmScriptRunner.StdErr))

0 commit comments

Comments
 (0)