{"version":3,"sources":["../src/inject.ts"],"names":[],"mappings":";AA8BA,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAChC,OAAO,EAAC,YAAY,EAAC,MAAM,QAAQ,CAAC;AAOpC,qBAAa,MAAM;IAClB,SAAgB,MAAM,EAAE,YAAY,CAAC;IACrC,SAAgB,GAAG,EAAE,MAAM,CAAC;gBAMhB,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY;IAahC,OAAO,CACnB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC;CASlC","file":"inject.d.ts","sourcesContent":["/**\n *\tMIT License\n *\n *\tCopyright (c) 2019 - 2022 Toreda, Inc.\n *\n *\tPermission is hereby granted, free of charge, to any person obtaining a copy\n *\tof this software and associated documentation files (the \"Software\"), to deal\n *\tin the Software without restriction, including without limitation the rights\n *\tto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n *\tcopies of the Software, and to permit persons to whom the Software is\n *\tfurnished to do so, subject to the following conditions:\n\n * \tThe above copyright notice and this permission notice shall be included in all\n * \tcopies or substantial portions of the Software.\n *\n * \tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n *\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n *\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * \tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n *\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n *\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * \tSOFTWARE.\n *\n */\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst nunjucksRender = require('gulp-nunjucks-render');\n\nimport {dest, src} from 'gulp';\n\nimport {Config} from './config';\nimport {EventEmitter} from 'events';\n\n/**\n * Inject data and replace values in template files.\n *\n * @category Inject\n */\nexport class Inject {\n\tpublic readonly events: EventEmitter;\n\tpublic readonly cfg: Config;\n\n\t/**\n\t * @param cfg \t\t\tGlobal config instance.\n\t * @param events \t\tGlobal EventEmitter instance.\n\t */\n\tconstructor(cfg: Config, events: EventEmitter) {\n\t\tif (!events) {\n\t\t\tthrow new Error('Inject init - events arg missing.');\n\t\t}\n\n\t\tif (!cfg) {\n\t\t\tthrow new Error('Inject init - cfg arg missing.');\n\t\t}\n\n\t\tthis.events = events;\n\t\tthis.cfg = cfg;\n\t}\n\n\tpublic async content(\n\t\tcontent: string,\n\t\ttemplatePath: string,\n\t\tsrcPattern: string,\n\t\tdstPath: string\n\t): Promise<NodeJS.ReadWriteStream> {\n\t\treturn src(srcPattern)\n\t\t\t.pipe(\n\t\t\t\tnunjucksRender({\n\t\t\t\t\tpath: [templatePath]\n\t\t\t\t})\n\t\t\t)\n\t\t\t.pipe(dest(dstPath));\n\t}\n}\n"]}