Skip to content

Commit 70594ab

Browse files
authored
Merge pull request #1670 from paulvanbrenk/debugArguments
Actually use project arguments when debugging
2 parents cf7f764 + 59eb4a3 commit 70594ab

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

Nodejs/Product/Nodejs/Project/NodejsProjectLauncher.cs

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
1+
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
22

33
using System;
44
using System.Collections.Generic;
@@ -407,13 +407,18 @@ private void StartWithChromeV2Debugger(string file, string nodePath, bool startB
407407
var webBrowserUrl = GetFullUrl();
408408
var envVars = GetEnvironmentVariables(webBrowserUrl);
409409

410+
var runtimeArguments = ConvertArguments(this._project.GetProjectProperty(NodeProjectProperty.NodeExeArguments));
411+
var scriptArguments = ConvertArguments(this._project.GetProjectProperty(NodeProjectProperty.ScriptArguments));
412+
410413
var cwd = _project.GetWorkingDirectory(); // Current working directory
411414
var configuration = new JObject(
412415
new JProperty("name", "Debug Node.js program from Visual Studio"),
413416
new JProperty("type", "node2"),
414417
new JProperty("request", "launch"),
415418
new JProperty("program", file),
419+
new JProperty("args", scriptArguments),
416420
new JProperty("runtimeExecutable", nodePath),
421+
new JProperty("runtimeArgs", runtimeArguments),
417422
new JProperty("cwd", cwd),
418423
new JProperty("console", "externalTerminal"),
419424
new JProperty("env", JObject.FromObject(envVars)),
@@ -436,30 +441,31 @@ private void StartWithChromeV2Debugger(string file, string nodePath, bool startB
436441

437442
var processInfo = new VsDebugTargetProcessInfo[debugTargets.Length];
438443

439-
var debugger = serviceProvider.GetService(typeof(SVsShellDebugger)) as IVsDebugger4;
444+
var debugger = (IVsDebugger4)serviceProvider.GetService(typeof(SVsShellDebugger));
440445
debugger.LaunchDebugTargets4(1, debugTargets, processInfo);
441446

442447
// Launch browser
443-
if (startBrowser)
448+
if (startBrowser && !string.IsNullOrWhiteSpace(webBrowserUrl))
444449
{
445-
Uri uri = null;
446-
if (!String.IsNullOrWhiteSpace(webBrowserUrl))
447-
{
448-
uri = new Uri(webBrowserUrl);
449-
}
450+
var uri = new Uri(webBrowserUrl);
451+
OnPortOpenedHandler.CreateHandler(
452+
uri.Port,
453+
shortCircuitPredicate: () => false,
454+
action: () =>
455+
{
456+
VsShellUtilities.OpenBrowser(webBrowserUrl, (uint)__VSOSPFLAGS.OSP_LaunchNewBrowser);
457+
}
458+
);
459+
}
460+
}
450461

451-
if (uri != null)
452-
{
453-
OnPortOpenedHandler.CreateHandler(
454-
uri.Port,
455-
shortCircuitPredicate: () => false,
456-
action: () =>
457-
{
458-
VsShellUtilities.OpenBrowser(webBrowserUrl, (uint)__VSOSPFLAGS.OSP_LaunchNewBrowser);
459-
}
460-
);
461-
}
462+
private static string[] ConvertArguments(string argumentString)
463+
{
464+
if (argumentString != null)
465+
{
466+
return argumentString.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
462467
}
468+
return Array.Empty<string>();
463469
}
464470

465471
private void LaunchDebugger(IServiceProvider provider, VsDebugTargetInfo dbgInfo)

0 commit comments

Comments
 (0)