{"version":3,"sources":["task-runner/gulp.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,MAAM,WAAW,WAAW;IACxB,QAAQ,EAAE,MAAM,GAAG,EAAE,CAAC,eAAe,CAAC;IACtC,MAAM,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,cAAc,CAAC,EAAE,QAAQ,EAAE,MAAa,EAAE,EAAE,WAAW,8BAetE;AAED,wBAAgB,aAAa,CAAC,YAAY,EAAE,MAAM,sBAUjD","file":"gulp.d.ts","sourcesContent":["import { compileFile } from '@src/compile';\nimport Through from 'through2';\nimport Vinyl from 'vinyl';\nimport { readFileSync } from 'fs';\nimport ts from 'typescript';\n\n/** Gulp options */\nexport interface GulpOptions {\n\ttsConfig: string | ts.CompilerOptions;\n\tpretty?: boolean;\n}\n/** Adapter for gulp */\nexport function createGulpPipe({\n\ttsConfig,\n\tpretty = true\n}: GulpOptions) {\n\tif (typeof tsConfig === 'string') tsConfig = parseTsConfig(tsConfig);\n\n\treturn Through.obj(function (\n\t\tfile: Vinyl,\n\t\t_: any,\n\t\tcb: Through.TransformCallback\n\t) {\n\t\tif (file.extname === '.ts') {\n\t\t\t// generate model\n\t\t\tvar content = compileFile(\n\t\t\t\tfile.path,\n\t\t\t\tfile.isBuffer()\n\t\t\t\t\t? file.contents.toString('utf-8')\n\t\t\t\t\t: readFileSync(file.path, 'utf-8'),\n\t\t\t\ttsConfig as ts.CompilerOptions,\n\t\t\t\tpretty\n\t\t\t);\n\t\t\tif (typeof content === 'string') {\n\t\t\t\tfile.contents = Buffer.from(content);\n\t\t\t}\n\t\t}\n\t\tcb(null, file);\n\t});\n}\n\n/** Parse tsConfig */\nexport function parseTsConfig(tsConfigPath: string) {\n\t//* Parse tsConfig\n\tvar tsP = ts.parseConfigFileTextToJson(\n\t\ttsConfigPath,\n\t\treadFileSync(tsConfigPath, 'utf-8')\n\t);\n\tif (tsP.error)\n\t\tthrow new Error(\n\t\t\t'Config file parse fails:' + tsP.error.messageText.toString()\n\t\t);\n\tvar tsP2 = ts.convertCompilerOptionsFromJson(\n\t\ttsP.config.compilerOptions,\n\t\tprocess.cwd(),\n\t\ttsConfigPath\n\t);\n\tif (tsP2.errors?.length)\n\t\tthrow new Error(\n\t\t\t'Config file parse fails:' +\n\t\t\ttsP2.errors.map(e => e.messageText.toString())\n\t\t);\n\treturn tsP2.options;\n}\n"]}