{"version":3,"file":"readable_file.js","sourceRoot":"","sources":["../src/readable_file.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA+B;AAC/B,+BAA4B;AAE5B;IAAkC,gCAAI;IACpC,sBAAmB,KAAyE;QAA5F,YACE,kBAAM,KAAK,CAAC,SACb;QAFkB,WAAK,GAAL,KAAK,CAAoE;;IAE5F,CAAC;IAED,sBAAI,iCAAO;aAAX;YAAA,iBAcC;YAbC,OAAO,CAAC;;;;;;4BACN,IAAI,IAAI,CAAC,YAAY;gCAAE,sBAAO,IAAI,CAAC,YAAY,EAAC;;;;4BAE9C,KAAA,IAAI,CAAA;4BAAgB,qBAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,EAAA;;4BAAxD,GAAK,YAAY,GAAG,SAAoC,CAAC;4BACzD,sBAAO,IAAI,CAAC,YAAY,EAAC;;;4BAEzB,UAAI,IAAI,CAAC,KAAK,0CAAE,cAAc,EAAE;gCAC9B,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC;gCAC9C,sBAAO,IAAI,CAAC,YAAY,EAAC;6BAC1B;4BACD,MAAM,GAAC,CAAC;;;;iBAEX,CAAC,EAAE,CAAC;QACP,CAAC;;;OAAA;IACH,mBAAC;AAAD,CAAC,AApBD,CAAkC,WAAI,GAoBrC;AApBY,oCAAY","sourcesContent":["import * as fs from 'fs-extra';\nimport {Path} from './path';\n\nexport class ReadableFile extends Path {\n constructor(public props?: ConstructorParameters[0] & {defaultContent?: string}) {\n super(props);\n }\n cacheContent?: string;\n get content() {\n return (async () => {\n if (this.cacheContent) return this.cacheContent;\n try {\n this.cacheContent = await fs.readFile(this.path, 'utf8');\n return this.cacheContent;\n } catch (e) {\n if (this.props?.defaultContent) {\n this.cacheContent = this.props.defaultContent;\n return this.cacheContent;\n }\n throw e;\n }\n })();\n }\n}\n"]}