From 3abd38dc23e0d6e50cbf261279b3d3de8e1ae9e4 Mon Sep 17 00:00:00 2001 From: CSUwangj Date: Fri, 19 Nov 2021 02:06:26 +0800 Subject: [PATCH] fix: test do not accept multple line string --- package-lock.json | 14 ++++++++++++++ package.json | 1 + src/commands/test.ts | 3 ++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 76397db2..f92a7e5b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "lodash": "^4.17.21", "markdown-it": "^8.4.2", "require-from-string": "^2.0.2", + "shell-quote": "^1.7.3", "unescape-js": "^1.1.4", "vsc-leetcode-cli": "2.8.1" }, @@ -1546,6 +1547,14 @@ "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" }, + "node_modules/shell-quote": { + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.4.tgz", + "integrity": "sha512-8o/QEhSSRb1a5i7TFR0iM4G16Z0vYB2OQVs4G3aAFXjn3T6yEx8AZxy1PgDF7I00LZHYA3WxaSYIf5e5sAX8Rw==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/signal-exit": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz", @@ -3345,6 +3354,11 @@ "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" }, + "shell-quote": { + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.4.tgz", + "integrity": "sha512-8o/QEhSSRb1a5i7TFR0iM4G16Z0vYB2OQVs4G3aAFXjn3T6yEx8AZxy1PgDF7I00LZHYA3WxaSYIf5e5sAX8Rw==" + }, "signal-exit": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz", diff --git a/package.json b/package.json index db0d475a..3e32405b 100644 --- a/package.json +++ b/package.json @@ -728,6 +728,7 @@ "lodash": "^4.17.21", "markdown-it": "^8.4.2", "require-from-string": "^2.0.2", + "shell-quote": "^1.7.3", "unescape-js": "^1.1.4", "vsc-leetcode-cli": "2.8.1" } diff --git a/src/commands/test.ts b/src/commands/test.ts index d070c9aa..7e02f59a 100644 --- a/src/commands/test.ts +++ b/src/commands/test.ts @@ -11,6 +11,7 @@ import { DialogType, promptForOpenOutputChannel, showFileSelectDialog } from ".. import { getActiveFilePath } from "../utils/workspaceUtils"; import * as wsl from "../utils/wslUtils"; import { leetCodeSubmissionProvider } from "../webview/leetCodeSubmissionProvider"; +import { quote } from "shell-quote"; export async function testSolution(uri?: vscode.Uri): Promise { try { @@ -89,7 +90,7 @@ export async function testSolution(uri?: vscode.Uri): Promise { function parseTestString(test: string): string { if (wsl.useWsl() || !isWindows()) { - return `'${test}'`; + return quote([`'${test}'`]); } // In windows and not using WSL