UNPKG

1.34 kBJavaScriptView Raw
1"use strict";exports.__esModule=!0;var tslib_1=require("tslib"),LarkLogger_1=require("@kemao/lark/Server/Log/LarkLogger/LarkLogger"),FileSystemWatch_1=require("@kemao/package-tools/FileSystemWatch/FileSystemWatch"),FileSystemWatchDto_1=require("@kemao/package-tools/FileSystemWatch/FileSystemWatchDto"),fs=require("fs-extra"),Path=require("path"),logger=new LarkLogger_1.LarkLogger("ConfigAsset"),ConfigAsset=function(){function e(){this.watch=!1,this.rootDir="./",this.sourceDir="config",this.outDir="build/config",this.eventMap={change:function(e){logger.log(e)},end:function(){}}}return e.prototype.addEventListener=function(e,t){this.eventMap[e]=t},e.prototype.build=function(){return tslib_1.__awaiter(this,void 0,void 0,function(){var t,s=this;return tslib_1.__generator(this,function(e){switch(e.label){case 0:return!1===fs.existsSync("config")?[2]:((t=new FileSystemWatch_1.FileSystemWatch).setRootDir(this.rootDir+"/"+this.sourceDir),t.setWatch(this.watch),t.addEventListener("data",function(e){var t=Path.resolve(s.rootDir+"/"+s.sourceDir),r=e.filename.replace(t,""),i=Path.resolve(s.rootDir+"/"+s.outDir+r),o=Path.dirname(i);fs.ensureDirSync(o),fs.copyFileSync(e.filename,i),e.mode===FileSystemWatchDto_1.E_FILE_MODE.CHANGE&&s.eventMap.change(e)}),[4,t.on()]);case 1:return e.sent(),[2]}})})},e}();exports.ConfigAsset=ConfigAsset;
\No newline at end of file