@lcap/builder
Version:
lcap builder utils
34 lines (33 loc) • 1.23 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getComponentPathInfo = void 0;
const fs_extra_1 = __importDefault(require("fs-extra"));
const path_1 = __importDefault(require("path"));
const getComponentPathInfo = (compName, rootPath, componentsPath) => {
const rootComponentDir = path_1.default.join(rootPath, componentsPath);
let componentDir = path_1.default.join(rootComponentDir, compName);
const srcCompDir = path_1.default.join(rootPath, `./src/${compName}`);
let sourceDir = componentsPath;
let symbol = compName;
// 兼容 mobile-ui 处理
if (!fs_extra_1.default.existsSync(componentDir)) {
if (fs_extra_1.default.existsSync(srcCompDir)) {
componentDir = srcCompDir;
sourceDir = 'src';
}
else {
const name = `${componentDir}.vue`;
componentDir = name;
symbol = `${compName}.vue`;
}
}
return {
componentDir,
sourceDir,
symbol,
};
};
exports.getComponentPathInfo = getComponentPathInfo;