bruno/packages/bruno-lang/v2/src/jsonToEnv.js
2023-02-05 19:06:48 +05:30

26 lines
449 B
JavaScript

const _ = require('lodash');
const envToJson = (json) => {
const variables = _.get(json, 'variables', []);
const vars = variables.map((variable) => {
const { name, value, enabled } = variable;
const prefix = enabled ? '' : '~';
return ` ${prefix}${name}: ${value}`;
});
if(!vars || !vars.length) {
return `vars {
}
`;
}
const output = `vars {
${vars.join('\n')}
}
`;
return output;
};
module.exports = envToJson;