{"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;CACpE,QAAQ,QAAR;EACE,KAAK,SACH,OAAO,KAAK,MAAM,QAAQ;EAC5B,KAAK;EACL,KAAK,SACH,OAAO,KAAK,MAAM,QAAQ;EAC5B,SACE,MAAM,IAAI,MAAM,wBAAwB,QAAQ;CACpD;AACF;AAEA,MAAa,mBACX,MACA,MACA,mBACG;CACH,MAAM,SAASA,gBAAAA,QAAQ,IAAI;CAE3B,IACE,CAAC,CAAC,SAAS,OAAO,CAAC,CAAC,SAAS,MAAM,KAClC,kBAAkB,CAAC,eAAe,SAAS,MAAM,GAElD,MAAM,IAAI,MAAM,wBAAwB,QAAQ;CAGlD,OAAO,iBAAiB,MAAM,MAAM;AACtC"}