{"version":3,"sources":["../../src/utilities/readIndexConfig.js"],"names":["directoryPath","indexPath","resolve","indexContents","readFileSync","found","match","configLine","trim","length","config","JSON","parse","error","Error"],"mappings":";;;;;;AAAA;;;;AACA;;;;AACA;;;;AACA;;;;kBAEgBA,aAAD,IAAmB;AAChC,MAAI,CAAC,wBAASA,aAAT,CAAL,EAA8B;AAC5B,WAAO,EAAP;AACD;;AAED,QAAMC,YAAY,eAAKC,OAAL,CAAaF,aAAb,EAA4B,UAA5B,CAAlB;AACA,QAAMG,gBAAgB,aAAGC,YAAH,CAAgBH,SAAhB,EAA2B,OAA3B,CAAtB;AACA,QAAMI,QAAQF,cAAcG,KAAd,iCAAd;AACA,QAAMC,aAAa,OAAOF,MAAM,CAAN,CAAP,KAAoB,QAApB,GAA+BA,MAAM,CAAN,EAASG,IAAT,EAA/B,GAAiD,EAApE;;AAEA,MAAID,WAAWE,MAAX,KAAsB,CAA1B,EAA6B;AAC3B,WAAO,EAAP;AACD;;AAED,MAAIC,MAAJ;;AAEA,MAAI;AACFA,aAASC,KAAKC,KAAL,CAAWL,UAAX,CAAT;AACD,GAFD,CAEE,OAAOM,KAAP,EAAc;AACd,UAAM,IAAIC,KAAJ,CACJ,MAAMb,SAAN,GAAkB,4CAAlB,GACA,4CAFI,CAAN;AAID;;AAED,SAAOS,MAAP;AACD,C","file":"readIndexConfig.js","sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport hasIndex from './hasIndex';\nimport {CREATE_INDEX_PATTERN} from './constants';\n\nexport default (directoryPath) => {\n if (!hasIndex(directoryPath)) {\n return {};\n }\n\n const indexPath = path.resolve(directoryPath, 'index.js');\n const indexContents = fs.readFileSync(indexPath, 'utf-8');\n const found = indexContents.match(CREATE_INDEX_PATTERN);\n const configLine = typeof found[1] === 'string' ? found[1].trim() : '';\n\n if (configLine.length === 0) {\n return {};\n }\n\n let config;\n\n try {\n config = JSON.parse(configLine);\n } catch (error) {\n throw new Error(\n '\"' + indexPath + '\" contains invalid configuration object.\\n' +\n 'Configuration object must be a valid JSON.'\n );\n }\n\n return config;\n};\n"]}