typed-serverless
Version:
Helps you write a consistent Serverless Framework configuration in TypeScript
21 lines (20 loc) • 734 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.replaceValue = void 0;
const logger_1 = require("./logger");
function replaceValue(parent, key, path, newValue) {
if (logger_1.traceEnabled)
(0, logger_1.trace)(`Replacing ${path.join('.')} with`, newValue);
if (Array.isArray(parent) || typeof parent === 'object') {
if (parent) {
if (key) {
parent[key] = newValue;
if (logger_1.traceEnabled)
(0, logger_1.trace)("Parent after replacing:", parent);
return;
}
}
}
throw new Error(`Failed to replace value at ${path.join('.')}`);
}
exports.replaceValue = replaceValue;