@platformatic/config
Advanced tools
Comparing version 0.7.0 to 0.8.0
14
index.js
@@ -29,3 +29,3 @@ 'use strict' | ||
} else { | ||
this.fullPath = join(tmpdir(), `platformatic-config-${Date.now()}.json`) | ||
this.fullPath = join(tmpdir(), `platformatic-config-${process.pid}-${Date.now()}.json`) | ||
this.current = opts.source | ||
@@ -143,3 +143,9 @@ this._shouldSave = true | ||
this.env = this.purgeEnv(env) | ||
return this.pupa(configString, this.env) | ||
const escapeNewlines = ({ value }) => { | ||
if (!value) return value | ||
return value.replace(/\n/g, '\\n') | ||
} | ||
return this.pupa(configString, this.env, { transform: escapeNewlines }) | ||
} | ||
@@ -175,3 +181,5 @@ | ||
} | ||
throw new Error(`Cannot parse config file. ${err.message}`) | ||
const newerr = new Error(`Cannot parse config file. ${err.message}`) | ||
newerr.cause = err | ||
throw newerr | ||
} | ||
@@ -178,0 +186,0 @@ } |
{ | ||
"name": "@platformatic/config", | ||
"version": "0.7.0", | ||
"version": "0.8.0", | ||
"description": "Platformatic DB Config Manager", | ||
@@ -24,3 +24,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"@platformatic/utils": "0.7.0", | ||
"@platformatic/utils": "0.8.0", | ||
"@iarna/toml": "^2.2.5", | ||
@@ -27,0 +27,0 @@ "ajv": "^8.11.0", |
@@ -86,1 +86,27 @@ 'use strict' | ||
}) | ||
test('transform placeholders with newlines', async ({ plan, same }) => { | ||
const cm = new ConfigManager({ | ||
source: './file.json', | ||
env: { | ||
PLT_FOO: 'bar\nbar2\nbar3', | ||
PLT_USERNAME: 'john\njohn2' | ||
} | ||
}) | ||
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\nbar2\nbar3' | ||
} | ||
}) | ||
}) |
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
1415
51006
20
+ Added@platformatic/utils@0.8.0(transitive)
- Removed@platformatic/utils@0.7.0(transitive)
Updated@platformatic/utils@0.8.0