style: optimize packaging code

This commit is contained in:
就眠儀式 2022-02-17 10:27:15 +08:00
parent 229f2da5fe
commit e64697a99b

View File

@ -1,25 +1,19 @@
/**
* merge less file
* <p>
*/
var fs = require('fs');
var { resolve } = require('path');
var fs = require('fs');
var { resolve } = require('path');
const inputDir = resolve(__dirname, './src/component')
const inputDir = resolve(__dirname, './src/component')
const inputsArray = fs.readdirSync(inputDir).filter((name) => {
const componentDir = resolve(inputDir, name)
const isDir = fs.lstatSync(componentDir).isDirectory()
return isDir && fs.readdirSync(componentDir).includes('index.ts')
})
// 读取基础变量 与 公共样式
var content = fs.readFileSync("./src/theme/variable.less").toString() + '\n\n';
content += fs.readFileSync("./src/theme/index.less").toString() + '\n\n';
const inputsArray = fs.readdirSync(inputDir).filter((name) => {
const componentDir = resolve(inputDir, name);
const isDir = fs.lstatSync(componentDir).isDirectory();
return isDir && fs.readdirSync(componentDir).includes('index.ts');
});
// 组件样式
inputsArray.forEach(function (f) {
var path = "./src/component/" + f + "/index.less";
var content = fs.readFileSync("./src/theme/variable.less").toString() + '\n\n';
content += fs.readFileSync("./src/theme/index.less").toString() + '\n\n';
inputsArray.forEach(function (f) {
var path = "./src/component/" + f + "/index.less";
fs.exists(path,function(exists){
if(exists){
var c = fs.readFileSync(path);
@ -29,4 +23,4 @@
fs.writeFileSync('./lib/index.less',content);
}
});
})
})