forked from Tencent/tdesign-vue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mv.js
46 lines (40 loc) · 1.16 KB
/
mv.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
41
42
43
44
45
46
const fs = require('fs');
const path = require('path');
const util = require('util');
const exec = util.promisify(require('child_process').exec);
// const scripts = {
// example: ``,
// };
function getComponentsName(dir) {
const arr = fs.readdirSync(dir);
const target = [];
arr.forEach((item) => {
const filePath = path.join(dir, item);
if (fs.lstatSync(filePath).isDirectory()) {
target.push(item);
}
});
return target;
}
const comps = [...new Set(getComponentsName('src'))];
console.log(comps);
async function gitMv(comp, source, destination) {
if (fs.existsSync(source) && fs.existsSync(`src/${comp}`)) {
const script = `git mv ${source} ${destination}`;
const { stderr } = await exec(script);
if (stderr) {
console.error('stderr:', stderr);
}
}
}
comps.forEach(async (comp) => {
// examples
// await gitMv(comp, `examples/${comp}/demos/`, `src/${comp}/_example`);
// usage
// await gitMv(comp, `examples/${comp}/usage/`, `src/${comp}/_usage`);
// md
// await gitMv(comp, `examples/${comp}/*.md`, `src/${comp}/`);
// unit
await gitMv(comp, `test/unit/${comp}/`, `src/${comp}/_tests_`);
});
// git clean -fd