-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
47 lines (45 loc) · 1.32 KB
/
main.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
47
var helper = require('./steps/helper');
var config = require('./config');
require('./get-cookie-and-starturl.js')(config.user.username, config.user.password, config.baseUrl, config.selectors)
.spread(function(startUrl, cookie) {
helper.setCookie(cookie);
helper.setStartUrl(startUrl);
})
.then(logAndExec(
'>> Step1: Getting courses',
require('./steps/1-get-courses.js')
))
.then(logAndExec(
'>> Step2: Cleaning up tree',
require('./steps/2-cleanup-tree.js')
))
.then(logAndExec(
'>> Step3: Getting module details',
require('./steps/3-get-module-details.js')
))
.then(logAndExec(
'>> Step4: Parsing module details',
require('./steps/4-parse-module-details.js')
))
.then(logAndExec(
'>> Step5: Merge module details',
require('./steps/5-merge-module-details.js')
))
.then(logAndExec(
'>> Step6: Sanitizing',
require('./steps/6-sanitize')
))
.then(logAndExec(
'>> Finished!',
process.exit.bind(process, 0)
))
.catch(function(err) {
console.error('Error retrieving modules:', err);
process.exit(1);
});
function logAndExec(msg, fn) {
return function() {
console.log(msg);
return fn.apply(null, arguments);
};
}