Skip to content

Commit 6952035

Browse files
committed
[Tv Shows] added grunt tasks
1 parent 90d9467 commit 6952035

File tree

4 files changed

+88
-18
lines changed

4 files changed

+88
-18
lines changed

Gruntfile.js

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,33 @@
1-
var fs = require('fs');
2-
var proposals = require('./data/proposals');
3-
var buildChunk = require('./tools/build_chunk');
41
module.exports = function(grunt) {
52

6-
grunt.registerTask('proposals', "Build proposals list", function() {
7-
proposals.forEach(function(chunk) {
8-
buildChunk(chunk);
9-
});
10-
});
11-
12-
grunt.registerTask('default', ['proposals']);
3+
grunt.initConfig({
4+
exec: {
5+
all: {
6+
command : 'node ./tools/build.js all true'
7+
},
8+
"fullseries": {
9+
command : 'node ./tools/build.js series true'
10+
},
11+
"fullproposals": {
12+
command : 'node ./tools/build.js proposals true'
13+
},
14+
series: {
15+
command : 'node ./tools/build.js series false'
16+
},
17+
"proposals": {
18+
command : 'node ./tools/build.js proposals false'
19+
},
20+
"justdata": {
21+
command : 'node ./tools/build.js all false'
22+
},
23+
}
24+
})
25+
grunt.loadNpmTasks('grunt-exec');
1326

27+
grunt.registerTask('default', ['exec:series']);
28+
grunt.registerTask('all', ['exec:all']);
29+
grunt.registerTask('full-series', ['exec:fullseries']);
30+
grunt.registerTask('full-proposals', ['exec:fullproposals']);
31+
grunt.registerTask('proposals', ['exec:proposals']);
32+
grunt.registerTask('data', ['exec:justdata']);
1433
};

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"download": "~0.1.10",
88
"request": "~2.34.0",
99
"async-each": "~0.1.4",
10-
"async": "^0.6.0"
10+
"async": "^0.6.0",
11+
"grunt-exec": "~0.4.5"
1112
}
1213
}

tools/build.js

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@ var series = require('../data/data');
55
var proposals = require('../data/proposals');
66
var buildChunk = require('./build_chunk');
77

8+
// build what(all, series, proposal) downlaod(true, false);
9+
10+
11+
buildChunk.download(process.argv[3]);
12+
813
var buildList = function(list, filename, variable, callback) {
914
var finalChunks = [];
10-
each(list, buildChunk, function(err, newChunks) {
15+
each(list, buildChunk.build, function(err, newChunks) {
1116
newChunks.forEach(function(chunk){
1217
finalChunks.push(chunk.omdb);
1318
});
@@ -24,9 +29,47 @@ var buildList = function(list, filename, variable, callback) {
2429
});
2530
}
2631

27-
buildList(proposals, 'proposals.js', 'toConsider', function() {
28-
console.log('Proposals finished, goin\' fo da rest nigga');
32+
var buildProposals = function(callback) {
33+
buildList(proposals, 'proposals.js', 'toConsider', function() {
34+
console.log('Proposals build finished...');
35+
if (typeof callback === 'function') {
36+
callback();
37+
}
38+
});
39+
}
40+
41+
var buildSeries = function(callback) {
2942
buildList(series, 'series.js', 'series', function() {
30-
console.log('LOL, DONE!');
43+
console.log('Series build finished...');
44+
if (typeof callback === 'function') {
45+
callback();
46+
}
3147
});
32-
});
48+
}
49+
50+
switch (process.argv[2]) {
51+
case 'all':
52+
buildProposals(
53+
buildSeries(
54+
function() {
55+
console.log('Building finished...');
56+
}
57+
)
58+
);
59+
break;
60+
case 'series':
61+
buildSeries(
62+
function() {
63+
console.log('Building finished...');
64+
}
65+
);
66+
break;
67+
case 'proposals':
68+
buildProposals(
69+
function() {
70+
console.log('Building finished...');
71+
}
72+
);
73+
default:
74+
console.log('Wrong parameters!');
75+
}

tools/build_chunk.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ var async = require('async');
77
var request = require('request');
88
var download = require('download');
99

10+
var download_covers = true;
11+
1012
var buildChunk = function(chunkb, callback) {
1113
async.parallel({
1214
github: async.apply(votesAction, chunkb),
@@ -44,7 +46,7 @@ var omdbAction = function(chunko, callback) {
4446
return callback(null);
4547
}
4648

47-
if (resp.poster && resp.poster !== "N/A") {
49+
if (resp.poster && resp.poster !== "N/A" && download_covers) {
4850
var dw = download({
4951
url: resp.poster,
5052
name: chunko.title.toLowerCase().replace(/[^A-Za-z0-9]/gi, '-') + '.jpg'
@@ -82,4 +84,9 @@ var omdbAction = function(chunko, callback) {
8284
//callback();
8385
}
8486

85-
module.exports = buildChunk;
87+
module.exports = {
88+
build: buildChunk,
89+
download: function(value) {
90+
download_covers = value;
91+
}
92+
}

0 commit comments

Comments
 (0)