perst
Version:
perst is a wrapper around LoaderIO, which can be configured and run in your commandline multiple tests and validates the measureable values like AVG Response Time and AVG Error Rate.
29 lines (25 loc) • 677 B
JavaScript
import YAML from 'yaml';
/**
*
* @param {string} filepath
* @param {string} content
* @param {Object} environment
* @return {Object}
*/
function yamlLoader(filepath, content, environment) {
content = Object.keys(environment).reduce(
(content, variable) => content.replace(new RegExp(`\\$${variable}|\\$\{${variable}\}`, 'g'), environment[variable]),
content
);
try {
return YAML.parse(content, {
prettyErrors: true,
merge: true
});
}
catch (error) {
error.message = `YAML Error in ${filepath}:\n${error.message}`;
throw error;
}
}
export { yamlLoader as default };