Skip to content

Commit 5d5e443

Browse files
author
Étienne Lévesque
committed
fix: Use single instead of double quotes and escape nested quotes
1 parent 06b1d27 commit 5d5e443

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/commands/runTestFromCodeLens.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,23 @@ export default function runFromCodeLens(args: RunArgs): void {
1818
elixirLsTerminal.sendText(buildTestCommand(args))
1919
}
2020

21+
function escapeSingleQuotes(s: string): string {
22+
return isWindows() ? s : s.replace(/'/g, "'\\''");
23+
}
24+
25+
function quote(s: string): string {
26+
const q = isWindows() ? '"' : `'`;
27+
return [q, s, q].join('');
28+
}
29+
30+
function isWindows(): boolean {
31+
return process.platform.includes('win32');
32+
}
33+
2134
function buildTestCommand(args: RunArgs): string {
2235
const testFilter = buildTestInclude(args.describe, args.testName, args.module)
2336

24-
return `mix test --exclude test --include "${testFilter}" ${args.filePath}`
37+
return `mix test --exclude test --include ${quote(escapeSingleQuotes(testFilter))} ${args.filePath}`
2538
}
2639

2740
function buildTestInclude(describe: string | null, testName?: string, module?: string) {

0 commit comments

Comments
 (0)