Skip to content

Commit

Permalink
feat: replace all values that match the pattern in file (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
jlenon7 authored Dec 15, 2021
1 parent 92f2871 commit e84332c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions manifest/templates/config-map.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ metadata:
namespace: default
data:
HOST: "{{ HOST }}"
APP_URL: "{{ HOST }}:{{ PORT }}"
PORT: "{{ PORT }}"
NODE_ENV: "{{ NODE_ENV }}"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jlenon7/templating",
"version": "1.0.9",
"version": "1.1.0",
"description": "",
"license": "MIT",
"author": "João Lenon",
Expand Down
2 changes: 1 addition & 1 deletion src/Templating.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class Templating {
private logger = new Logger(Templating.name)

private matcher(key?: string) {
if (key) return new RegExp(`{{\\s*${key}\\s*}}`)
if (key) return new RegExp(`{{\\s*${key}\\s*}}`, 'g')

return /{{\s*.*\s*}}/g
}
Expand Down
2 changes: 2 additions & 0 deletions tests/templating.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe('\n Templating Class', () => {
expect(configMapTemplate.includes('3000')).toBe(true)
expect(configMapTemplate.includes('production')).toBe(true)
expect(configMapTemplate.includes('http://127.0.0.1')).toBe(true)
expect(configMapTemplate.includes('http://127.0.0.1:3000')).toBe(true)
})

it('should be able to format environment variables and extra fields', async () => {
Expand All @@ -51,6 +52,7 @@ describe('\n Templating Class', () => {
expect(configMapTemplate.includes('3000')).toBe(true)
expect(configMapTemplate.includes('production')).toBe(true)
expect(configMapTemplate.includes('http://127.0.0.1')).toBe(true)
expect(configMapTemplate.includes('http://127.0.0.1:3000')).toBe(true)
expect(deploymentTemplate.includes('jlenon7/templating:latest')).toBe(true)
})

Expand Down

0 comments on commit e84332c

Please sign in to comment.