Skip to content

Commit 3517777

Browse files
Étienne Lévesqueaxelson
Étienne Lévesque
authored andcommitted
fix: Use single instead of double quotes and escape nested quotes
1 parent 9eca95d commit 3517777

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
@@ -19,14 +19,27 @@ export default function runFromCodeLens(args: RunArgs): void {
1919
elixirLsTerminal.sendText(buildTestCommand(args));
2020
}
2121

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

29-
return `mix test --exclude test --include "${testFilter}" ${args.filePath}`;
42+
return `mix test --exclude test --include ${quote(escapeSingleQuotes(testFilter))} ${args.filePath}`;
3043
}
3144

3245
function buildTestInclude(

0 commit comments

Comments
 (0)