UNPKG

1.16 kBSource Map (JSON)View Raw
1{"version":3,"file":"writeReadme.js","sourceRoot":"","sources":["writeReadme.ts"],"names":[],"mappings":";;;;;;AAAA,uCAAoD;AAEpD,+DAA6C;AAC7C,2BAAmC;AAEnC,SAAgB,WAAW,CAAC,OAG3B;IAEA,IAAI,qBAAU,CAAC,OAAO,CAAC,IAAI,CAAC,EAC5B;QACC,IAAI,GAAG,GAAG,uBAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;QAChD,IAAI,QAAQ,GAAG,kBAAc,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE;QAC7C,0BAA0B;SAC1B,CAAC,CAAA;QAEF,IAAI,GAAG,GAAG,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;QAEpC,IAAI,GAAG,KAAK,GAAG,EACf;YACC,kBAAa,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;SAChC;KACD;AACF,CAAC;AAnBD,kCAmBC","sourcesContent":["import { existsSync, readFileSync } from \"fs-extra\";\nimport { join } from \"path\";\nimport lodashTemplate from 'lodash/template';\nimport { writeFileSync } from \"fs\";\n\nexport function writeReadme(options: {\n\tfile: string,\n\tvariable: Record<any, any>,\n})\n{\n\tif (existsSync(options.file))\n\t{\n\t\tlet md1 = readFileSync(options.file).toString();\n\t\tlet compiled = lodashTemplate(md1.toString(), {\n\t\t\t//escape: new RegExp('_'),\n\t\t})\n\n\t\tlet md2 = compiled(options.variable)\n\n\t\tif (md1 !== md2)\n\t\t{\n\t\t\twriteFileSync(options.file, md2)\n\t\t}\n\t}\n}\n"]}
\No newline at end of file