MCPcopy
hub / github.com/faressoft/terminalizer / loadYAML

Function loadYAML

utility.js:103–121  ·  view source on GitHub ↗

* Check, load, and parse YAML files * * - Add .yml extension when needed * * Throws * - The provided file doesn't exit * - The provided file is not a valid YAML file * - Any reading errors * * @param {String} filePath an absolute or a relative path * @return {Object}

(filePath)

Source from the content-addressed store, hash-verified

101 * @return {Object}
102 */
103function loadYAML(filePath) {
104
105 var file = loadFile(filePath, 'yml');
106
107 // Parse the file
108 try {
109
110 return {
111 json: di.yaml.load(file),
112 raw: file.toString()
113 };
114
115 } catch (error) {
116
117 throw new Error('The provided file is not a valid YAML file');
118
119 }
120
121}
122
123/**
124 * Check, load, and parse JSON files

Callers 1

getDefaultConfigFunction · 0.85

Calls 1

loadFileFunction · 0.85

Tested by

no test coverage detected