forked from Netcentric/fe-build
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtaskVerification.js
More file actions
38 lines (33 loc) · 1.25 KB
/
taskVerification.js
File metadata and controls
38 lines (33 loc) · 1.25 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
const path = require('path');
const { log, color } = require('./log');
module.exports = (configuration, taskFolder = '../tasks/') => {
log(__filename, `Tasks started with mode - ${color('green', configuration.general.mode)}`);
if (configuration && configuration.general && configuration.general.task) {
try {
/* eslint-disable */
// Exception to dinamic require of tasks
const execute = require(`${taskFolder}${configuration.general.task}`);
/* eslint-enable */
execute(configuration);
} catch (e) {
log(__filename, e.message, '', 'info');
try {
/* eslint-disable */
// try as a abs path script (external tasks) project scripts and share config
const execute = require(path.resolve(`${configuration.general.task}`));
/* eslint-enable */
execute(configuration);
} catch (error) {
log(__filename, `Cannot find task to execute ${configuration.general.task}`, '', 'error');
}
}
} else {
// run all default default async
configuration.general.defaultTasks.forEach((taskName) => {
/* eslint-disable */
const task = require(`${taskFolder}${taskName}`);
/* eslint-enable */
setTimeout(() => task(configuration));
});
}
};