lambda-serverless-api
Advanced tools
Comparing version 1.10.2 to 1.10.3
@@ -8,21 +8,18 @@ const fs = require("fs"); | ||
const loadRecursive = (dir, data, vars) => { | ||
Object.keys(data).forEach((key) => { | ||
let entry = get(data, key); | ||
if (typeof entry === 'string' || entry instanceof String) { | ||
// replace yaml variables with defaults | ||
entry = entry.replace(/\${opt:([a-zA-Z0-9]+?)(?:, ["']([a-zA-Z0-9]+?)["'])?}/g, (_, k, v) => get(vars, k, v)); | ||
// load referenced yaml file | ||
const match = /^\${file\((~?[a-zA-Z0-9._\-/]+?)\)(?::([a-zA-Z0-9.]+?))?}$/g.exec(entry); | ||
if (match) { | ||
const filePath = path.join(dir, match[1]); | ||
const loaded = yaml.safeLoad(fs.readFileSync(filePath, 'utf8')); | ||
entry = loadRecursive(dir, match[2] ? get(loaded, match[2]) : loaded, vars); | ||
} | ||
let result = data; | ||
if (typeof result === 'string' || result instanceof String) { | ||
// replace yaml variables with defaults | ||
result = result.replace(/\${opt:([a-zA-Z0-9]+?)(?:, ["']([a-zA-Z0-9]+?)["'])?}/g, (_, k, v) => get(vars, k, v)); | ||
// load referenced yaml file | ||
const match = /^\${file\((~?[a-zA-Z0-9._\-/]+?)\)(?::([a-zA-Z0-9.]+?))?}$/g.exec(result); | ||
if (match) { | ||
const filePath = path.join(dir, match[1]); | ||
const loaded = yaml.safeLoad(fs.readFileSync(filePath, 'utf8')); | ||
result = loadRecursive(dir, match[2] ? get(loaded, match[2]) : loaded, vars); | ||
} | ||
if (entry instanceof Object) { | ||
entry = loadRecursive(dir, entry, vars); | ||
} | ||
set(data, key, entry); | ||
}); | ||
return data; | ||
} | ||
if (result instanceof Object) { | ||
Object.keys(result).forEach(key => set(result, key, loadRecursive(dir, get(result, key), vars))); | ||
} | ||
return result; | ||
}; | ||
@@ -29,0 +26,0 @@ |
@@ -23,3 +23,3 @@ { | ||
}, | ||
"version": "1.10.2", | ||
"version": "1.10.3", | ||
"scripts": { | ||
@@ -26,0 +26,0 @@ "test": "grunt gardener", |
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
18230
350