forked from zhangkun-Jser/code-recheck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
26 lines (22 loc) · 819 Bytes
/
index.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
/*
* @Author: zk
* @Date: 2019-12-19 20:35:48
* @LastEditTime : 2019-12-21 18:30:27
* @Description: 优化模块入口
*/
const codeDuplicateScanner = require('./src/codeDuplicateScanner');
const cloneRepoIfNeeded = require('./src/cloneRepoIfNeeded');
const runTask = async ({projectInfo, output, ext, ignore, user, password}) => {
await cloneRepoIfNeeded(projectInfo, user, password);
await codeDuplicateScanner(projectInfo, output, ext, ignore);
};
const check = ({list, path: output, ...rest}) => {
if(!Array.isArray(list)) throw new Error('传入的参数必须是数组')
list.reduce(
(thenable, projectInfo) => {
return thenable.then(_ => runTask({projectInfo, output, ...rest})).catch(error => console.log('error', {error}));
},
Promise.resolve()
)
}
module.exports = check;