-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-demo-name.js
40 lines (35 loc) · 1.06 KB
/
build-demo-name.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var fs = require("fs")
var join = require('path').join;
function getJsonFiles(jsonPath) {
let jsonFiles = [];
function findJsonFile(path) {
let files = fs.readdirSync(path);
files.forEach(function (item, index) {
let fPath = join(path, item);
let stat = fs.statSync(fPath);
if (stat.isDirectory() === true) {
findJsonFile(fPath);
}
if (stat.isFile() === true) {
jsonFiles.push(fPath);
}
});
}
findJsonFile(jsonPath);
return jsonFiles;
}
const componentMap = {};
getJsonFiles("./src/components/demo/").forEach(fileName => {
const i = fileName.lastIndexOf("\\");
const tempName = fileName.slice(i + 1);
if (tempName.indexOf(".vue")) {
componentMap[tempName.replace(".vue", "")] = false;
}
});
fs.writeFile('./src/assets/config/demo-comps.json', JSON.stringify(componentMap), function (error) {
if (error) {
console.log('写入失败')
} else {
console.log('写入成功了')
}
})