@platformatic/config
Advanced tools
Comparing version 0.12.1 to 0.13.0
@@ -135,8 +135,11 @@ 'use strict' | ||
const escapeNewlines = ({ value }) => { | ||
const escapeJSONstring = ({ value }) => { | ||
if (!value) return value | ||
return value.replace(/\n/g, '\\n') | ||
// TODO this shoudl handle all the escapes chars | ||
// defined in https://www.json.org/json-en.html | ||
// but it's good enough for now. | ||
return value.replace(/\\/g, '\\\\').replace(/\n/g, '\\n') | ||
} | ||
return this.pupa(configString, this.env, { transform: escapeNewlines }) | ||
return this.pupa(configString, this.env, { transform: escapeJSONstring }) | ||
} | ||
@@ -143,0 +146,0 @@ |
{ | ||
"name": "@platformatic/config", | ||
"version": "0.12.1", | ||
"version": "0.13.0", | ||
"description": "Platformatic DB Config Manager", | ||
@@ -29,3 +29,3 @@ "main": "index.js", | ||
"yaml": "^2.1.3", | ||
"@platformatic/utils": "0.12.1" | ||
"@platformatic/utils": "0.13.0" | ||
}, | ||
@@ -32,0 +32,0 @@ "scripts": { |
@@ -112,1 +112,27 @@ 'use strict' | ||
}) | ||
test('transform placeholders with `\\`', async ({ plan, same }) => { | ||
const cm = new ConfigManager({ | ||
source: './file.json', | ||
env: { | ||
PLT_FOO: 'bar\\.bar2\\.bar3', | ||
PLT_USERNAME: 'john\\.john2' | ||
} | ||
}) | ||
const config = { | ||
server: { | ||
hostname: '127.0.0.1', | ||
port: '3042', | ||
replace: '{PLT_FOO}' | ||
} | ||
} | ||
const res = await cm.replaceEnv(JSON.stringify(config)) | ||
same(JSON.parse(res), { | ||
server: { | ||
hostname: '127.0.0.1', | ||
port: '3042', | ||
replace: 'bar\\.bar2\\.bar3' | ||
} | ||
}) | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43709
1113
+ Added@platformatic/utils@0.13.0(transitive)
- Removed@platformatic/utils@0.12.1(transitive)
Updated@platformatic/utils@0.13.0