forked from MailOnline/videojs-vast-vpaid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
83 lines (69 loc) · 2.42 KB
/
gulpfile.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
var requireDir = require('require-dir');
var asciify = require('asciify');
var gulp = require('gulp');
var async = require('async');
var Table = require('cli-table');
var BuildTaskDoc = require('./build/BuildTaskDoc');
//Init colors
require('./build/COLORS');
//We retrieve the build-tasks
var buildTasksMap = requireDir('./build');
gulp.task('default', function (finishTask) {
async.series([
printWelcomeMessage,
printBanner,
printTasksHelpTable
],
finishTask
);
/*** Local functions ***/
function printWelcomeMessage(done) {
console.log("Welcome to MailOnline's new".info);
done(null);
}
function printBanner(done) {
asciify('Videojs Vast Vpaid', function (err, res) {
console.log(res.help);
done(null);
});
}
function printTasksHelpTable(done) {
var table = new Table({
head: ['Name', 'Description'],
colWidths: [25, 80],
chars: { 'top': '═' , 'top-mid': '╤' , 'top-left': '╔' , 'top-right': '╗'
, 'bottom': '═' , 'bottom-mid': '╧' , 'bottom-left': '╚' , 'bottom-right': '╝'
, 'left': '║' , 'left-mid': '╟' , 'mid': '─' , 'mid-mid': '┼'
, 'right': '║' , 'right-mid': '╢' , 'middle': '│' }
});
var buildTasks = getBuildTasks(buildTasksMap);
buildTasks.forEach(function (task) {
table.push([task.name, task.description]);
});
console.log('###### Below, you have the list of all the available build tasks ########');
console.log(table.toString());
//console.log(' ');
//console.log("NOTE: if a task is run with '--env production' it will execute the build task for production. Minifying scritps and so on".blue);
console.log(' ');
done(null);
}
function getBuildTasks(tasksDir) {
var tasks = [];
Object.keys(tasksDir).forEach(function (taskName) {
var task = tasksDir[taskName];
if(task instanceof BuildTaskDoc){
tasks.push(task);
}
});
return tasks.sort(function compare(a, b) {
if (a.order < b.order) {
return -1;
}
if (a.order > b.order) {
return 1;
}
// a must be equal to b
return 0;
});
}
});