File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed
PowerShellEditorServices.Protocol/Server
PowerShellEditorServices/Session Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -97,14 +97,22 @@ protected async Task HandleLaunchRequest(
97
97
98
98
await editorSession . PowerShellContext . ExecuteCommand ( setWorkingDirCommand ) ;
99
99
100
- Logger . Write ( LogLevel . Verbose , "Working dir set to '" + workingDir + "'" ) ;
100
+ Logger . Write ( LogLevel . Verbose , "Working dir set to: " + workingDir ) ;
101
+
102
+ // Prepare arguments to the script - if specified
103
+ string arguments = null ;
104
+ if ( ( launchParams . Args != null ) && ( launchParams . Args . Length > 0 ) )
105
+ {
106
+ arguments = string . Join ( " " , launchParams . Args ) ;
107
+ Logger . Write ( LogLevel . Verbose , "Script arguments are: " + arguments ) ;
108
+ }
101
109
102
110
// Execute the given PowerShell script and send the response.
103
111
// Note that we aren't waiting for execution to complete here
104
112
// because the debugger could stop while the script executes.
105
113
Task executeTask =
106
114
editorSession . PowerShellContext
107
- . ExecuteScriptAtPath ( launchParams . Program )
115
+ . ExecuteScriptAtPath ( launchParams . Program , arguments )
108
116
. ContinueWith (
109
117
async ( t ) => {
110
118
Logger . Write ( LogLevel . Verbose , "Execution completed, terminating..." ) ;
Original file line number Diff line number Diff line change @@ -432,16 +432,22 @@ public async Task<IEnumerable<object>> ExecuteScriptString(
432
432
/// Executes a script file at the specified path.
433
433
/// </summary>
434
434
/// <param name="scriptPath">The path to the script file to execute.</param>
435
+ /// <param name="arguments">Arguments to pass to the script.</param>
435
436
/// <returns>A Task that can be awaited for completion.</returns>
436
- public async Task ExecuteScriptAtPath ( string scriptPath )
437
+ public async Task ExecuteScriptAtPath ( string scriptPath , string arguments = null )
437
438
{
438
439
// If we don't escape wildcard characters in the script path, the script can
439
440
// fail to execute if say the script name was foo][.ps1.
440
441
// Related to issue #123.
441
442
string escapedScriptPath = EscapeWildcardsInPath ( scriptPath ) ;
442
443
444
+ if ( arguments != null )
445
+ {
446
+ escapedScriptPath += " " + arguments ;
447
+ }
448
+
443
449
PSCommand command = new PSCommand ( ) ;
444
- command . AddCommand ( escapedScriptPath ) ;
450
+ command . AddScript ( escapedScriptPath ) ;
445
451
446
452
await this . ExecuteCommand < object > ( command , true ) ;
447
453
}
You can’t perform that action at this time.
0 commit comments