{"version":3,"file":"parse.cjs","names":["extname"],"sources":["../../src/util/parse.ts"],"sourcesContent":["import * as yaml from \"yaml\";\nimport { extname } from \"./extname.js\";\n\nexport const loadFileContents = (contents: string, format: string) => {\n  switch (format) {\n    case \".json\":\n      return JSON.parse(contents);\n    case \".yml\":\n    case \".yaml\":\n      return yaml.parse(contents);\n    default:\n      throw new Error(`Unsupported filetype ${format}`);\n  }\n};\n\nexport const parseFileConfig = (\n  text: string,\n  path: string,\n  supportedTypes?: string[]\n) => {\n  const suffix = extname(path);\n\n  if (\n    ![\".json\", \".yaml\"].includes(suffix) ||\n    (supportedTypes && !supportedTypes.includes(suffix))\n  ) {\n    throw new Error(`Unsupported filetype ${suffix}`);\n  }\n\n  return loadFileContents(text, suffix);\n};\n"],"mappings":";;;;;AAGA,MAAa,oBAAoB,UAAkB,WAAmB;AACpE,SAAQ,QAAR;EACE,KAAK,QACH,QAAO,KAAK,MAAM,SAAS;EAC7B,KAAK;EACL,KAAK,QACH,QAAO,KAAK,MAAM,SAAS;EAC7B,QACE,OAAM,IAAI,MAAM,wBAAwB,SAAS;;;AAIvD,MAAa,mBACX,MACA,MACA,mBACG;CACH,MAAM,SAASA,gBAAAA,QAAQ,KAAK;AAE5B,KACE,CAAC,CAAC,SAAS,QAAQ,CAAC,SAAS,OAAO,IACnC,kBAAkB,CAAC,eAAe,SAAS,OAAO,CAEnD,OAAM,IAAI,MAAM,wBAAwB,SAAS;AAGnD,QAAO,iBAAiB,MAAM,OAAO"}