-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
52 lines (39 loc) · 1.02 KB
/
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const skeletor = () => {
const configManager = require('./lib/configManager')();
const taskRunner = require('./lib/taskRunner');
let logger = require('./lib/consoleLogger')();
const setLogger = newLogger => {
logger = newLogger;
};
const setConfig = config => {
configManager.setConfig(config);
};
const getConfig = () => configManager.getConfig();
const runTask = (taskName, options = {}) => {
try {
configManager.getConfig();
} catch (e) {
const errorMsg = `Configuration Error -- ${e}`;
logger.error(errorMsg);
return Promise.reject(errorMsg);
}
const taskConfig = configManager.getTaskConfig(taskName);
if(taskConfig === undefined) {
const errorMsg = `ERROR: Could not find task "${taskName}"`;
logger.error(errorMsg);
return Promise.reject(errorMsg);
}
if(!options.logger) {
options.logger = logger;
}
return taskRunner.runTask(taskConfig, options, api);
};
const api = {
getConfig,
setConfig,
setLogger,
runTask
};
return api;
};
module.exports = skeletor;