* 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)
| 101 | * @return {Object} |
| 102 | */ |
| 103 | function 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 |
no test coverage detected