From bb73bdf4f95e0f4b5cd7a71c7242719f5a618ba6 Mon Sep 17 00:00:00 2001 From: MaxKless <34165455+MaxKless@users.noreply.github.com> Date: Wed, 26 Jun 2024 14:38:54 +0200 Subject: [PATCH] fix(vscode): escape quotes in windows powershell (#2189) Signed-off-by: Max Kless --- libs/vscode/utils/src/lib/shell-execution.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libs/vscode/utils/src/lib/shell-execution.ts b/libs/vscode/utils/src/lib/shell-execution.ts index c4b4702126..52cfe81757 100644 --- a/libs/vscode/utils/src/lib/shell-execution.ts +++ b/libs/vscode/utils/src/lib/shell-execution.ts @@ -2,7 +2,7 @@ import { importNxPackagePath } from '@nx-console/shared/npm'; import type { PackageManagerCommands } from 'nx/src/utils/package-manager'; import { platform } from 'os'; -import { ShellExecution } from 'vscode'; +import { ShellExecution, workspace } from 'vscode'; export interface ShellConfig { cwd: string; @@ -34,6 +34,16 @@ export async function getShellExecutionForConfig( command = `${pmc.exec} ${command}`; } + const isPowershell = + platform() === 'win32' && + workspace + .getConfiguration('terminal') + .get('integrated.defaultProfile.windows') === 'PowerShell'; + + if (isPowershell) { + command = command.replace(/"/g, '\\"'); + } + return new ShellExecution(command, { cwd: config.cwd, });