diff --git a/src/parser.test.ts b/src/parser.test.ts index 7a06904..4b6a17f 100644 --- a/src/parser.test.ts +++ b/src/parser.test.ts @@ -4,7 +4,7 @@ import { parseString } from "./parser"; const JOBS = ` NAME post with token CRON * * * * * -POST $APP_URL/api/post?token=$TOKEN +POST $\{APP_URL\}/api/post?token=$TOKEN Content-Type: application/json { diff --git a/src/parser.ts b/src/parser.ts index 9e013c9..9bca657 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -11,10 +11,13 @@ export function parseString(fileContent: string, variables = {}) { return jobs.map((job) => createJob(job)); } -function inject(fileContent: string, variables: Record) { +export function inject(fileContent: string, variables: Record) { let res = fileContent; Object.keys(variables).map( - (v) => (res = res.replaceAll(`\$${v}`, variables[v])) + (v) => + (res = res + .replaceAll(`\$${v}`, variables[v]) + .replaceAll(`\$\{${v}\}`, variables[v])) ); return res; }