diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/data/language.js | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/data/language.js b/src/data/language.js index 99eaa58f..aed16057 100644 --- a/src/data/language.js +++ b/src/data/language.js @@ -4,6 +4,7 @@ import path from 'node:path'; import chokidar from 'chokidar'; import he from 'he'; // It stands for "HTML Entities", apparently. Cursed. +import yaml from 'js-yaml'; import T from '#things'; import {colors, logWarn} from '#cli'; @@ -56,11 +57,18 @@ async function processLanguageSpecFromFile(file, processLanguageSpecOpts) { error => annotateErrorWithFile(error, file)); } + let parseLanguage; try { - spec = JSON.parse(contents); + if (path.extname(file) === '.yaml') { + parseLanguage = 'YAML'; + spec = yaml.load(contents); + } else { + parseLanguage = 'JSON'; + spec = JSON.parse(contents); + } } catch (caughtError) { throw annotateError( - new Error(`Failed to parse language file as valid JSON`, {cause: caughtError}), + new Error(`Failed to parse language file as valid ${parseLanguage}`, {cause: caughtError}), error => annotateErrorWithFile(error, file)); } |