@getcoconut/cli
Version:
A tool for locally emulating and mocking Pulumi Cloud projects.
46 lines • 1.68 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.unmarshalOutputs = exports.writeOutputs = exports.getOutputTargetFile = void 0;
const fs = require("fs-extra");
const path = require("path");
const config = require("./config");
const errors_1 = require("./errors");
function getOutputTargetFile(target) {
return path.resolve(target, 'coconut.json');
}
exports.getOutputTargetFile = getOutputTargetFile;
function writeOutputs(outputs, stack) {
var _a, _b;
const targetFiles = [];
const timestamp = new Date();
(_b = (_a = config.get().outputs) === null || _a === void 0 ? void 0 : _a.targets) === null || _b === void 0 ? void 0 : _b.forEach((target) => {
const targetFile = getOutputTargetFile(target);
const targetContent = {
stack,
timestamp,
outputs,
};
try {
process.stdout.write(`writing outputs to ${targetFile}...`);
fs.outputJSONSync(targetFile, targetContent, { spaces: 2 });
console.info('done.');
targetFiles.push(targetFile);
}
catch (err) {
console.info('failed!');
throw new errors_1.CustomError(err.message);
}
});
return targetFiles;
}
exports.writeOutputs = writeOutputs;
function unmarshalOutputs(outputs) {
const unmarashled = Object.keys(outputs).reduce((unmarashled, key) => {
var _a;
unmarashled[key] = (_a = outputs[key]) === null || _a === void 0 ? void 0 : _a.value;
return unmarashled;
}, {});
return unmarashled;
}
exports.unmarshalOutputs = unmarshalOutputs;
//# sourceMappingURL=utils.js.map