elmer-ui-core
Version:
web app framework
61 lines (60 loc) • 2.77 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.StaticBuilder = void 0;
var BaseBuilder_1 = require("./BaseBuilder");
var StaticBuilder = (function (_super) {
__extends(StaticBuilder, _super);
function StaticBuilder(fs, srcPath, desPath) {
var _this = _super.call(this, fs) || this;
_this.srcPath = srcPath;
_this.desPath = desPath;
_this.io = fs;
return _this;
}
StaticBuilder.prototype.setSrcPath = function (path) {
this.srcPath = path;
};
StaticBuilder.prototype.setDesPath = function (path) {
this.desPath = path;
};
StaticBuilder.prototype.run = function () {
var _this = this;
if (this.isExists(this.srcPath) && this.isExists(this.desPath)) {
var srcRootPath_1 = this.srcPath.replace(/\\/g, "/").replace(/\/$/, "");
console.log(this.formatLog("Source: " + srcRootPath_1, BaseBuilder_1.EnumLogType.INFO));
console.log(this.formatLog("Build: " + this.desPath, BaseBuilder_1.EnumLogType.INFO));
this.scanFiles(this.srcPath, function (fileName) {
if (!/(\.ts)$/.test(fileName)) {
var tmpSrcRootPath = srcRootPath_1.replace(/\//g, "\\");
var tmpFileName = fileName.replace(/\//g, "\\");
var desFileName = tmpFileName.replace(tmpSrcRootPath, "");
var desPath = _this.desPath.replace(/\//g, "\\").replace(/\\$/, "");
var desFile = desPath + desFileName;
if (!/\.DS_Store$/.test(desFile)) {
_this.saveFile(desFile, _this.io.readFileSync(fileName));
}
}
});
}
else {
console.log(this.formatLog("请检查配置路径是否存在?", BaseBuilder_1.EnumLogType.WARNING));
}
};
return StaticBuilder;
}(BaseBuilder_1.BaseBuilder));
exports.StaticBuilder = StaticBuilder;