Skip to content

Commit a0314ed

Browse files
committed
Ensure subtitute is surrounded with the same quotes (#154)
1 parent bcba543 commit a0314ed

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

src/processor/generic-processor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export abstract class GenericProcessor {
3636
}
3737

3838
replaceSubstituteWithValue(substitute: string, value: string) {
39-
const match = new RegExp(`('|")?${substitute}('|")?`)
39+
const match = new RegExp(`'${substitute}'|"${substitute}"|${substitute}`)
4040
this.text = this.text.replace(match, value)
4141
}
4242
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { equal } from "assert"
2+
3+
import { HelmProcessor } from "../../../processor/helm-processor"
4+
5+
suite("Test GenericProcessor - replaceSubstituteWithValue()", () => {
6+
test("GitHub issue #154: Ensure a substitue is surrounded with the same quotation marks", () => {
7+
const text = "TABLE_SOURCES: 'vscode-yaml-sort.helm.0 TABLE'"
8+
const helmprocessor = new HelmProcessor(text)
9+
10+
helmprocessor.replaceSubstituteWithValue("vscode-yaml-sort.helm.0", "{{ LEVEL }}")
11+
12+
const expected = "TABLE_SOURCES: '{{ LEVEL }} TABLE'"
13+
14+
equal(helmprocessor.text, expected)
15+
})
16+
})

0 commit comments

Comments
 (0)