-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetFolders.js
More file actions
38 lines (36 loc) · 1.09 KB
/
Copy pathgetFolders.js
File metadata and controls
38 lines (36 loc) · 1.09 KB
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
/**
* Created by PanJiankang on 2018/8/5 下午5:39.
*/
const path = require('path');
const fs = require('fs');
const rootPaths = __dirname;
const promiseArr = [];
const getFolders = (rootPath) => {
fs.readdir(rootPath, (err, folders) => {
if (err) {
console.log(err);
return false;
}
const newList = folders.filter(item => item.indexOf('node_modules') === -1);
if (folders.includes('package.json')) {
// console.log( `<excludeFolder url="file://$MODULE_DIR$${rootPath.replace( __dirname, "" )}/node_modules" />` );
const content = `<excludeFolder url="file://$MODULE_DIR$${rootPath.replace(__dirname, '')}/dist" />`;
promiseArr.push(Promise.resolve(content));
}
newList.forEach((item) => {
const filePaths = path.resolve(rootPath, item);
fs.stat(filePaths, (er, stats) => {
const isDir = stats.isDirectory();
if (isDir) {
getFolders(filePaths);
}
});
});
});
};
Promise.resolve(getFolders(rootPaths)).then(() => {
console.log(promiseArr);
});
setTimeout(() => {
console.log(promiseArr);
}, 10000);