@@ -84,19 +84,14 @@ export class PesterTestsFeature implements vscode.Disposable {
8484 outputPath ?: string ) : vscode . DebugConfiguration {
8585
8686 const settings = getSettings ( ) ;
87-
88- // Since we pass the script path to PSES in single quotes to avoid issues with PowerShell
89- // special chars like & $ @ () [], we do have to double up the interior single quotes.
90- const scriptPath = fileUri . fsPath . replace ( / ' / g, "''" ) ;
91-
9287 const launchConfig = {
9388 request : "launch" ,
9489 type : "PowerShell" ,
9590 name : "PowerShell: Launch Pester Tests" ,
9691 script : this . invokePesterStubScriptPath ,
9792 args : [
9893 "-ScriptPath" ,
99- `'${ scriptPath } '` ,
94+ `'${ utils . escapeSingleQuotes ( fileUri . fsPath ) } '` ,
10095 ] ,
10196 internalConsoleOptions : "neverOpen" ,
10297 noDebug : ( launchType === LaunchType . Run ) ,
@@ -106,12 +101,7 @@ export class PesterTestsFeature implements vscode.Disposable {
106101 if ( lineNum ) {
107102 launchConfig . args . push ( "-LineNumber" , `${ lineNum } ` ) ;
108103 } else if ( testName ) {
109- // Escape single quotes inside double quotes by doubling them up
110- if ( testName . includes ( "'" ) ) {
111- testName = testName . replace ( / ' / g, "''" ) ;
112- }
113-
114- launchConfig . args . push ( "-TestName" , `'${ testName } '` ) ;
104+ launchConfig . args . push ( "-TestName" , `'${ utils . escapeSingleQuotes ( testName ) } '` ) ;
115105 } else {
116106 launchConfig . args . push ( "-All" ) ;
117107 }
0 commit comments